Jump to content

Checking a field in IE > Getting 'Variable must be of type Object"


Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...