Jump to content

Unable to get to the second instance of an Object by ID


climber
 Share

Recommended Posts

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?

 

Link to comment
Share on other sites

Link to comment
Share on other sites

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...

 

 

Link to comment
Share on other sites

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...

 

 

Link to comment
Share on other sites

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.  🙂

 

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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