Pagi Posted October 4, 2018 Share Posted October 4, 2018 Hello guys, I am still learning AutoIt, especially button clicks and I´ve got this problem. I dont´know how can I click the button without id, when there are other buttons with same class. Mb some index or something like that. I tried this method and it returns me error Func att() $oButtons = _IETagNameGetCollection ($oIE, "button") ; For $oButton In $oButtons If $oButton.class = "awesome-button" Then _IEAction ($oButton, "click") ExitLoop EndIf Next EndFunc <button class="awesome-button " onclick="click(null, '0', 1, 0, '')">Click</button> <button class="awesome-button " onclick="click(null, '0', 2, 0, '')">Click</button> <button class="awesome-button " onclick="click(null, '0', 3, 0, '')">Click</button> <button class="awesome-button " onclick="click(null, '0', 4, 0, '')">Click</button> Each button has the same text. The only different is between that numbers (I guess it´s some kind of index or something like that) Any advices? Link to comment Share on other sites More sharing options...
Developers Jos Posted October 4, 2018 Developers Share Posted October 4, 2018 (edited) Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team Seems you really have issues reading this warnings as this did happen before..... Edited October 4, 2018 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Gianni Posted October 4, 2018 Share Posted October 4, 2018 4 hours ago, Pagi said: .... I tried this method and it returns me error ... what error did you get? ( usually the error returned is useful to identify the problem.... ) Since you are working within a function scope, have you declared the $oIE variable as Global in the main script scope..? Also, have a look the third parameter of the _IETagNameGetCollection function, using that parameter you can select just one of the many buttons returned... Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
jdelaney Posted October 4, 2018 Share Posted October 4, 2018 What's the html like surrounding them? If, for an example, they are in a table, you can get the specific row, and find that rows button IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Pagi Posted October 7, 2018 Author Share Posted October 7, 2018 @Chimp "C:\Program Files (x86)\AutoIt3\Include\IE.au3" (1811) : ==> The requested action with this object has failed.: Return SetError($_IESTATUS_Success, $oTemp.GetElementsByTagName($sTagName).length, $oTemp.GetElementsByTagName($sTagName)) Return SetError($_IESTATUS_Success, $oTemp^ ERROR I get this error or script crashes And yes ofc I declared $oIE as Global. I know about that IETagNameGetCollection function there is an index which can I use but not working for me.. In this line I tried to add index $oButtons = _IETagNameGetCollection ($oIE, "button", 2) ; 2 is an index of 2nd button but it returns me similar error or script crashes @jdelaney No there is not any <table> tag if you mean that, just the <div> tag Link to comment Share on other sites More sharing options...
jdelaney Posted October 7, 2018 Share Posted October 7, 2018 (edited) Notice that your error is in reference to $oTemp, and your provided code does not include that variable. Unable to reproduce. Also, it doesn't NEED to be a table, that was just a suggestion. If the div includes some id or unique attribute, you can use that. If not, look at it's parent node up the chain until you do find something. Edit: ah, the function includes an $oTemp. Turn on the error handler, and you will be fine. _IEErrorHandlerRegister Edited October 7, 2018 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Danp2 Posted October 7, 2018 Share Posted October 7, 2018 @jdelaney It appears that the error is coming from within IE.au3 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
jdelaney Posted October 7, 2018 Share Posted October 7, 2018 (edited) Yeah, edited my last one. In my experience, the browser can periodically be in a state where the DOM is not accessible. The error handler will catch that, and proceed. Edited October 7, 2018 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. 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