climber Posted February 23, 2020 Posted February 23, 2020 I want to click the "next" button on a page. I had a piece of code that worked, but something changed about the page, and now it doesn't. What I was using, but is broken now: _IELinkClickByText($oIE, "next", 0, 1) It now gets @error = 7 ($_IEStatus_NoMatch) - No Match What I see in DOM Explorer in IE, is there are two buttons, side by side, with the same ID, distinguished from each other only by the button text. It appears on the page as <prev | next> The code is <span id="reviewsPagerLink_next" onclick="reviewsShowPage(0, -1);">prev</span> | <span id="reviewsPagerLink_next" onclick="reviewsShowPage(0, 1);">next</span> The only statement I've found that partially works now is _IEGetObjByID($oIE, "reviewsPagerLink_next")` But when I use _IEGetObjByID, I get only the first button, which is the "prev" button. What I need is the second instance, which is the "next" button. This function only returns one instance. When I use _IEGetObjByName, (which is capable of returning a collection), I don't get a hit at all. Searching for either "reviewsPagerLink_next" or just "next". @error = 7 ($_IEStatus_NoMatch) - No Match Any tips on how to get to the second instance of the "reviewsPagerLink_next", which is the real "next" button?
Danp2 Posted February 23, 2020 Posted February 23, 2020 You could try something like this -- $oSpan = _IEGetObjByID($oIE, "reviewsPagerLink_next") $oSpan.NextSibling.Click() Latest Webdriver UDF Release Webdriver Wiki FAQs
Nine Posted February 23, 2020 Posted February 23, 2020 Might not work since there is text in between. Use this if it doesn't work : $oSpan = _IEGetObjByID($oIE, "reviewsPagerLink_next") $oSpan.nextElementSibling.Click() “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
climber Posted February 23, 2020 Author Posted February 23, 2020 Thanks for the quick response. 👍 😀 I've framed it up to handle the first page which is simply "<next>", subsequent pages which are "<prev | next>", and the final page which is just "<prev>". MsgBox shows me I'm detecting/evaluating properly, so I have the flow laid out. But --- my AutoIt is not recognizing nextSibling.click or nextElementSibling.click. Is there another Include that's needed to support those? I searched a bit, but didn't find anything...
climber Posted February 23, 2020 Author Posted February 23, 2020 Thanks for the quick response. 👍 😀 I've framed it up to handle the first page which is simply "<next>", subsequent pages which are "<prev | next>", and the final page which is just "<prev>". MsgBox shows me I'm detecting/evaluating properly, so I have the flow laid out. But --- my AutoIt (version 3.3.14.4) is not recognizing nextSibling.click or nextElementSibling.click. Is there another Include that's needed to support those? I searched a bit, but didn't find anything...
climber Posted February 23, 2020 Author Posted February 23, 2020 edit - (or attempted edit)... My AutoIt is now updated to 3.3.14.5 after reading the sticky about that. So the remaining question - do I need to include another #include for these? Or perhaps I need to set up a For loop. Will try to do that next. 🙂
climber Posted February 23, 2020 Author Posted February 23, 2020 The loop didn't work. For $oSpan in $oSpan. Probably because _IEGetObjByID doesn't return a collection. So I'm still stuck on how to get nextElementSibling.Click() or nextElement.Click() to work. 😞
Nine Posted February 23, 2020 Posted February 23, 2020 Local $cSpans = _IETagNameGetCollection ($oIE, "span") For $oSpan in $cSpans If $oSpan.innerText = "next" Then $oSpan.click () ExitLoop EndIf Next if that doesn't work, it is probably because you have iframe somewhere... “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
climber Posted February 24, 2020 Author Posted February 24, 2020 That worked great, thank you! I added a boolean so I know if I'm at the end. (no "next" button found) Quote $bClickedNext = False Local $cSpans = _IETagNameGetCollection ($oIE, "span") For $oSpan in $cSpans If $oSpan.innerText = "next" Then $oSpan.click () $bClickedNext = True ExitLoop EndIf Next
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