CaptainBeardsEyesBeard Posted September 27, 2019 Share Posted September 27, 2019 So I'm getting this error "C:\Automation\GenericFunctions\GenericFunctions.au3" (111) : ==> Variable must be of type "Object".: if StringInStr($ObjID.innerText, $ObjExpected) then And it's on the first if statement line the debugger flags the variable as type object Func CheckAField_In_InternetExplorer_On_Inner_Text($ObjID, $ObjExpected, $FieldBeingTested) if StringInStr($ObjID.innerText, $ObjExpected) then MsgBox($MB_SYSTEMMODAL, "Test Result for field " & $FieldBeingTested, "Test Passed:" & $ObjExpected & " " & $FieldBeingTested & " matches the following value received "& $ObjID.innerText, 4) FileWrite($TestLog, @CRLF & "Test" & $TestCount & " Test Passed: " & $ObjExpected & " " & $FieldBeingTested & " matches the value expected " & $ObjID.innerText) FileWrite($TestResults, @CRLF & "Test" & $TestCount & " Test Passed: " & $ObjExpected & " " & $FieldBeingTested & " matches the value expected ") Else MsgBox($MB_SYSTEMMODAL, "Test Result ", "Test Failed:" & $ObjExpected & " " & $FieldBeingTested & " doesn't match following value received "& $ObjID.innerText & "", 4) FileWrite($TestLog, @CRLF & "Test " & $TestCount & " Test Failed:"& $ObjExpected & " " & $FieldBeingTested & " doesn't match the following value retrieved " & $ObjID.innerText) FileWrite($TestResults, @CRLF & "Test " & $TestCount & " Test Failed:"& $ObjExpected & " " & $FieldBeingTested & " doesn't match the following value retrieved ") Sleep(4000) EndIf $TestCount = $TestCount +1 EndFunc And in my main program I test this func like this Local $MainID = _IEGetObjById($oIE, "pageWrapper") CheckAField_In_InternetExplorer_On_Inner_Text($MainID, "Upload Costs", "Upload costs header exists") Any idea why I'm getting this? This function seems to work other times :S Link to comment Share on other sites More sharing options...
Danp2 Posted September 27, 2019 Share Posted September 27, 2019 Since it sounds like your call to IEGetObjById is failing, you should add some error checking to handle this. Another suggestion would be to add a line at the beginning of your function to check that $objID is actually an object. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now