Jump to content

Extracting a value from an IE Element - Error must be of type object


Recommended Posts

Hi 

I feel like I'm going mad as some of my old scripts aren't working so trying to return back to basics and fix them. 

I want to be able to pull data out of a box on IE for example and would like you to let me know if I'm doing it correctly..

 

So this is my html and it's just an text box (editable) 

Quote

<div class="row">
            <div class="col-md-8">
                <label class="label">Title</label>
                <input name="title" class="form-control valid" id="title" aria-invalid="false" aria-required="true" required="" type="text" maxlength="200" value="Mr Captain Birdseye v Cpt Blackbeard">
            </div>

 

So I just have this small snippet 

 

If WinActivate("Test app - Internet Explorer") Then
   WinSetState("Test app - Internet Explorer", "", @SW_MAXIMIZE)

   Sleep(4000)
Else


   EndIf
$oIE = _IEAttach("Test app - Internet Explorer")
Sleep(4000)
_IELoadWait($oIE)
$Test = _IEGetObjById($oIE, "title")
if @error then
   MsgBox($MB_SYSTEMMODAL, "Error handling" , "Error pulling attempting $Test = _IEGetObjById($oIE, 'submitDiv') " , 4)
   Endif

MsgBox($MB_SYSTEMMODAL, "blah" , $Test.value, 4)
MsgBox($MB_SYSTEMMODAL, "blah" , $Test.innerText, 4)
exit

And I get a following console output saying it must be of type Object

It also hits the @error check and produces the message box in the If statement

 

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Automation_Solcase\testdelete.au3"    
--> IE.au3 T3.0-2 Warning from function _IEAttach, $_IESTATUS_NoMatch
--> IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_InvalidDataType
--> IE.au3 T3.0-2 Error from function _IEGetObjById, $_IESTATUS_InvalidDataType
"C:\Automation_Solcase\testdelete.au3" (50) : ==> Variable must be of type "Object".:
MsgBox($MB_SYSTEMMODAL, "blah" , $Test.value, 4)
MsgBox($MB_SYSTEMMODAL, "blah" , $Test^ ERROR
>Exit code: 1    Time: 13.21

 

Edited by CaptainBeardsEyesBeard
Link to post
Share on other sites

@CaptainBeardsEyesBeard
The variable $oIE is not an object, and so, every other function which is trying to access an object, fails, and so, you have those errors.

Check the function _IEAttach(), and check if ir correctly returns an object with IsObj() function :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to post
Share on other sites

Even more checking at the very beginning :

Local $hWnd = WinGetHandle ("Test app - Internet Explorer")
if not $hWnd then Exit MsgBox (0,"","Unable to find window")
Local $oIE = _IEAttach ($hWnd, "hwnd")
if not isObj ($oIE) then Exit MsgBox (0,"","Not an object")

 

Link to post
Share on other sites
  • 2 weeks later...
On 1/10/2020 at 10:15 AM, FrancescoDiMuro said:

@CaptainBeardsEyesBeard
The variable $oIE is not an object, and so, every other function which is trying to access an object, fails, and so, you have those errors.

Check the function _IEAttach(), and check if ir correctly returns an object with IsObj() function :)

Oh man that's what I was missing! 

I had thought if you used IECREATE you wouldn't need IEATTACH 

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...