Jump to content

Error: Variable must be of type object - (Locked)


Recommended Posts

 

I am new to scripting and trying to figure out how to click a button on a website without MouseClick as that is inconsistent. I have tried several things but I'm still stuck with the error:

For $oButton In $oButtons

For $oButton In $oButtons^ ERROR

Error: Variable must be of type object

This is the code I am using

code.png.038008a06ee771a72c43ffae099606dc.png

Link to comment
Share on other sites

1 minute ago, jackster0306 said:

 

I am new to scripting and trying to figure out how to click a button on a website without MouseClick as that is inconsistent. I have tried several things but I'm still stuck with the error:

For $oButton In $oButtons

For $oButton In $oButtons^ ERROR

Error: Variable must be of type object

This is the code I am using

code.png.038008a06ee771a72c43ffae099606dc.png

Incase you can't see the picture:

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IEAttach("I put the URL here", 1)
If @extended Then
    MsgBox($MB_SYSTEMMODAL, "", "Attached to Existing Browser")
Else
    MsgBox($MB_SYSTEMMODAL, "", "Created New Browser")
EndIf
_IELoadWait($oIE)
Local $oButtons = _IETagNameGetCollection($oIE, "button")
    For $oButton In $oButtons
        If $oButton.InnerText = 'Search' Then
            MsgBox(64, 'Search Button Found', 'Button found with value: ' & $oButton.InnerText)
            ;_IEAction($oButton, click)
    EndIf
    Next

Link to comment
Share on other sites

Quote

Error: Variable must be of type object

Therefore, $oButtons must not be of type object.

Therefore, the assignment:

Local $oButtons = _IETagNameGetCollection($oIE, "button")

must not be returning an object.

Maybe, put this after the assignment statement and find out what’s going on...

If @Error Then MsgBox(1, "@Error is", @Error)

 

Code hard, but don’t hard code...

Link to comment
Share on other sites

Hi @jackster0306, and welcome to the AutoIt Forum :welcome:

Next time you post the code, please use the Code Tag <>, so the syntax is higlighted and it's not messy.

About your issue, seems that _IEAttach is failing becuse it is badly formatted; take a look at the function reference to see how you should use it.

Then, use error checking to see if every function returns a correct value :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

9 hours ago, JockoDundee said:

Therefore, $oButtons must not be of type object.

Therefore, the assignment:

Local $oButtons = _IETagNameGetCollection($oIE, "button")

must not be returning an object.

Maybe, put this after the assignment statement and find out what’s going on...

If @Error Then MsgBox(1, "@Error is", @Error)

 

I put in the error message and it has returned 3 which I have read means there is an invalid data type. I also put an error after the _IEAttach and it returned 7 meaning there is n match. I have changed the attach to IECreate and no longer get these errors however nothing happens so the button search must not find anything. Any idea what to do now?

Link to comment
Share on other sites

57 minutes ago, FrancescoDiMuro said:

Post the code you are using, always :)

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IECreate("https://www.ea.com/fifa/ultimate-team/web-app/",1)
If @Error Then MsgBox(1, "@Error is", @Error)
If @extended Then
    MsgBox($MB_SYSTEMMODAL, "", "Attached to Existing Browser")
Else
    MsgBox($MB_SYSTEMMODAL, "", "Created New Browser")
EndIf
_IELoadWait($oIE)
Local $oButtons = _IETagNameGetCollection($oIE, "button")
If @Error Then MsgBox(1, "@Error is", @Error)
    For $oButton In $oButtons
        If $oButton.InnerText = 'Search' Then
            MsgBox(64, 'Search Button Found', 'Button found with value: ' & $oButton.InnerText)
            ;_IEAction($oButton, click)
        EndIf
    Next

 

Link to comment
Share on other sites

Ok, if I am supposing right, you did not get any error with this code.  So it must be because, there is frames involved.  Look for it.  Then search forum for examples of how to use frame with IE.

Link to comment
Share on other sites

39 minutes ago, Nine said:

Ok, if I am supposing right, you did not get any error with this code.  So it must be because, there is frames involved.  Look for it.  Then search forum for examples of how to use frame with IE.

Yeah there is no error but I can't seem to find any frames

Link to comment
Share on other sites

Link to comment
Share on other sites

I do not see anything wrong.  Put a ConsoleWrite in the loop, outside the If to see if it is finding the buttons alright...try debugging the innerText using StringLen or StringInStr, to see if there is hidden characters. 

Link to comment
Share on other sites

11 minutes ago, Nine said:

I do not see anything wrong.  Put a ConsoleWrite in the loop, outside the If to see if it is finding the buttons alright...try debugging the innerText using StringLen or StringInStr, to see if there is hidden characters. 

The loop is occurring. I will try the other things you mentioned later and let you know how it goes.

Link to comment
Share on other sites

5 hours ago, Nine said:

I do not see anything wrong.  Put a ConsoleWrite in the loop, outside the If to see if it is finding the buttons alright...try debugging the innerText using StringLen or StringInStr, to see if there is hidden characters. 

StringLen gave me a return of 0

Link to comment
Share on other sites

45 minutes ago, FrancescoDiMuro said:

@jackster0306
Unfortunately, without having the choice to test directly the website, it's hard to see what has to be done.
Could you please post the last script you are using? :)

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IECreate("https://www.ea.com/fifa/ultimate-team/web-app/",1)
If @Error Then MsgBox(1, "@Error is", @Error)
If @extended Then
    MsgBox($MB_SYSTEMMODAL, "", "Attached to Existing Browser")
Else
    MsgBox($MB_SYSTEMMODAL, "", "Created New Browser")
EndIf
_IELoadWait($oIE)
Sleep(30000)
Local $oButtons = _IETagNameGetCollection($oIE, "button")
If @Error Then MsgBox(1, "@Error is", @Error)
    For $oButton In $oButtons
        If $oButton.InnerText = 'Search' Then
            MsgBox(64, 'Search Button Found', 'Button found with value: ' & $oButton.InnerText)
            ;_IEAction($oButton, click)
        EndIf
        Local $oString = StringInStr($oButton, "Search")
        MsgBox($MB_SYSTEMMODAL, "", $oString)
    Next

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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