superklamer Posted April 30, 2015 Share Posted April 30, 2015 (edited) 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 April 30, 2015 by superklamer Link to comment Share on other sites More sharing options...
Danp2 Posted April 30, 2015 Share Posted April 30, 2015 (edited) Links <> ButtonsTry using _IETagNameGetCollection.Edit1: Search the forum for "_IETagNameGetCollection button" and you'll find lots of threads on the subject. Edited April 30, 2015 by Danp2 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
superklamer Posted April 30, 2015 Author Share Posted April 30, 2015 Thanks, Danp2.Just using this:Local $oButs = _IETagNameGetCollection($oIE, "button") For $oBut In $oButs If StringInStr($oBut.innertext, "Favorite") Then _IEAction($oBut, "click") NextI 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 More sharing options...
Danp2 Posted April 30, 2015 Share Posted April 30, 2015 You should be able to use StringInStr along with $oBut.classname to determine if the "done" is present. superklamer 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
superklamer Posted April 30, 2015 Author Share Posted April 30, 2015 (edited) 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 April 30, 2015 by superklamer 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