Jump to content

Click on a IE button based on class name


Recommended Posts

Hello,

I am re-posting my topic because I have revised it a little bit.

I am trying to click on t a button that has no name or ID only class name.

This is the button code:

<button type="button" class="btn-fave                                          casanova-action done" data-source="listing" data-shop-id="50748261" data-shop-user-id="50748261" data-shop-shop-id="9743630" data-position="side" data-downtime-overlay-type="favorite" data-attribution-source="trending_item">
                <span class="icon"></span>
            <span class="default">
                                    Favorite
                            </span>
            <span class="done remove">
                Favorited
            </span>
        </button>

 

Does anybody have any idea how can I capture it and click on it?


I have tried using the _IETagNameGetCollection but it did not work.

This is what i had:

$oFound = ""
$colLinks = _IELinkGetCollection($oIE)
For $oLink In $colLinks
    If $oLink.className & "" = "btn-fave                                          casanova-action done" Then
        $oFound = $oLink
        ExitLoop
    EndIf
Next
If IsObj($oFound) Then
    MsgBox(64, "Success", "Found it!")
Else
    MsgBox(16, "Failed", "Not found.")
EndIf

 

Edited by superklamer
Link to comment
Share on other sites

Thanks, Danp2.

Just using this:

Local $oButs = _IETagNameGetCollection($oIE, "button")
For $oBut In $oButs
    If StringInStr($oBut.innertext, "Favorite") Then _IEAction($oBut, "click")
Next

I was able to click on the button. There's the catch: This s a "Favorite item button". The item might be favorited before or it might not. With the code, the way I have it now, I can click on the button only once, no matter if it is favorited before or not.

I was looking at the page source and the only thing I noticed changing when the item has not been favorited is the "done" in the class field. 

<button type="button" class="btn-fave                                          casanova-action done" data-source="listing" data-shop-id="50748261" data-shop-user-id="50748261" data-shop-shop-id="9743630" data-position="side" data-downtime-overlay-type="favorite" data-attribution-source="trending_item">
                <span class="icon"></span>
            <span class="default">
                                    Favorite
                            </span>
            <span class="done remove">
                Favorited
            </span>
        </button>
Link to comment
Share on other sites

Works like a charm!

Thank you Danp2!!! You just saved me countless hours and nerves trying to figure it out with Automation Anywhere ...

I'll say it again... AutoIT is the best! There's nothing AutoIT can't do.

Edited by superklamer
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...