jackster0306 Posted February 9, 2021 Posted February 9, 2021 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
jackster0306 Posted February 9, 2021 Author Posted February 9, 2021 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 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
JockoDundee Posted February 9, 2021 Posted February 9, 2021 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) FrancescoDiMuro 1 Code hard, but don’t hard code...
FrancescoDiMuro Posted February 9, 2021 Posted February 9, 2021 Hi @jackster0306, and welcome to the AutoIt Forum 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 TheXman 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
jackster0306 Posted February 9, 2021 Author Posted February 9, 2021 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?
FrancescoDiMuro Posted February 9, 2021 Posted February 9, 2021 6 minutes ago, jackster0306 said: Any idea what to do now? Post the code you are using, always Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
jackster0306 Posted February 9, 2021 Author Posted February 9, 2021 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
Nine Posted February 9, 2021 Posted February 9, 2021 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. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
jackster0306 Posted February 9, 2021 Author Posted February 9, 2021 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
Nine Posted February 9, 2021 Posted February 9, 2021 (edited) Can you show the DOM of the button ? (as much as you can, so we can see what is going on around the button) Edited February 9, 2021 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
jackster0306 Posted February 9, 2021 Author Posted February 9, 2021 22 minutes ago, Nine said: Can you show the DOM of the button ? (as much as you can, so we can see what is going on around the button)
Nine Posted February 9, 2021 Posted February 9, 2021 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. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
jackster0306 Posted February 9, 2021 Author Posted February 9, 2021 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.
jackster0306 Posted February 9, 2021 Author Posted February 9, 2021 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
FrancescoDiMuro Posted February 10, 2021 Posted February 10, 2021 @jackster0306 Testing the website you posted, there are no buttons found. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
jackster0306 Posted February 10, 2021 Author Posted February 10, 2021 8 hours ago, FrancescoDiMuro said: @jackster0306 Testing the website you posted, there are no buttons found. Not when you load it but you can login and then there are buttons, is there something else have to do to find the buttons after logging in?
FrancescoDiMuro Posted February 10, 2021 Posted February 10, 2021 @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? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
jackster0306 Posted February 10, 2021 Author Posted February 10, 2021 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
Nine Posted February 10, 2021 Posted February 10, 2021 Replace your loop with this one : For $oButton In $oButtons ConsoleWrite ($oButton.innerText & @CRLF) ConsoleWrite (StringToBinary($oButton.innerText) & @CRLF) Next And show the console after. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
jackster0306 Posted February 10, 2021 Author Posted February 10, 2021 16 minutes ago, Nine said: Replace your loop with this one : For $oButton In $oButtons ConsoleWrite ($oButton.innerText & @CRLF) ConsoleWrite (StringToBinary($oButton.innerText) & @CRLF) Next And show the console after. How do I see the console?
Recommended Posts