dar100111 Posted July 3, 2013 Posted July 3, 2013 (edited) Hi Everyone. I used the script below on a webpage I need to click a button on. It went through a ton of message boxes until it found the button I'm looking for. Tagname: BUTTON innerText:Go $oElements = _IETagNameAllGetCollection($oIE) For $oElement In $oElements MsgBox(0, "Element Info", "Tagname: " & $oElement.tagname & @CR & "innerText: " & $oElement.innerText) Next I'm not sure how to save the tag as a variable, let's call it $tag, so that I can _ieAction($tag, "click") to click on this button. Since it didn't have an ID I had to resort to this. Does anyone have any knowledge on the syntax for this? I'm just not sure how to tell it to save the exact tag on the webpage to my $tag. Attached a screenshot Thank you very much! Edited July 3, 2013 by dar100111
Danp2 Posted July 4, 2013 Posted July 4, 2013 What does the HTML look like for the desired element? Even if you had to loop through all of the elements until you found the one you wanted, you should be able to do something like this: $oElements = _IETagNameAllGetCollection($oIE) For $oElement In $oElements If $oElement.tagname = "BUTTON" And $oElement.innerText = "Go" Then _IEAction($oElement, "click") ExitLoop Endif Next Latest Webdriver UDF Release Webdriver Wiki FAQs
Moderators big_daddy Posted July 4, 2013 Moderators Posted July 4, 2013 ; Get a collection of all BUTTON objects $oButtons = _IETagNameGetCollection($oIE, "BUTTON") ; Loop through each element in the collection For $oButton In $oButtons ; check for an element with an innerText "Go" If String($oButton.innerText) = "Go" Then ; Save the current element to a variable $oButton2Save = $oButton ; Exit the for loop now that we have found the go button ExitLoop EndIf Next
Solution dar100111 Posted July 5, 2013 Author Solution Posted July 5, 2013 Man you guys rock. That worked. Saved me a lot of headache here!
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