zhaeldd Posted August 16, 2014 Share Posted August 16, 2014 So the problem is that I would like to click the second button while both buttons have the same value. With the code I'm using i can only get it to work with the first button. This is the code I'm using: $oLinks = _IETagNameGetCollection($oIE, "input") For $oLink In $oLinks If String($oLink.type) = "submit" And String($oLink.value) = "Hello world" Then $oLink = $oLink _IEAction($oLink, "click") ExitLoop EndIf Next Buttons source code: <div id="div1"> <form action='index.php' method=post><input type='hidden' value='0' name='test'> <input type='submit' value='Hello world'></form> </div> <div id="div1"> <form action='index.php' method=post><input type='hidden' value='1' name='test'> <input type='submit' value='Hello world'></form> </div> The only difference between buttons is value='0' and value='1', and It's in form. How would I be able to click the second button when my code is just clicking the first button it finds? Link to comment Share on other sites More sharing options...
Danp2 Posted August 16, 2014 Share Posted August 16, 2014 Add a counter to your code and then only execute the _IEAction / ExitLoop combo when the counter equals 2. You could also use _IEFormGetCollection to retrieve the desire form and then call _IEFormSubmit. $oLink = $oLink What's this line supposed to be doing? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
zhaeldd Posted August 17, 2014 Author Share Posted August 17, 2014 (edited) Add a counter to your code and then only execute the _IEAction / ExitLoop combo when the counter equals 2. You could also use _IEFormGetCollection to retrieve the desire form and then call _IEFormSubmit.$oLink = $oLinkWhat's this line supposed to be doing? How should I add the counter? I had that on mind but I couldn't create it. I thought about for loop but I guess I just wasn't creative enough. Edit: I guess that line is useless. Edited August 17, 2014 by zhaeldd Link to comment Share on other sites More sharing options...
Danp2 Posted August 17, 2014 Share Posted August 17, 2014 Here's one way: $oFlag = False $oLinks = _IETagNameGetCollection($oIE, "input") For $oLink In $oLinks If String($oLink.type) = "submit" And String($oLink.value) = "Hello world" Then If $oFlag Then _IEAction($oLink, "click") ExitLoop Else $oFlag = True EndIf EndIf Next Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
zhaeldd Posted August 18, 2014 Author Share Posted August 18, 2014 (edited) Here's one way: $oFlag = False $oLinks = _IETagNameGetCollection($oIE, "input") For $oLink In $oLinks If String($oLink.type) = "submit" And String($oLink.value) = "Hello world" Then If $oFlag Then _IEAction($oLink, "click") ExitLoop Else $oFlag = True EndIf EndIf Next Thanks for your help! Worked just as it should. Edited August 18, 2014 by zhaeldd 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