ILoveUBot 10 Posted April 2, 2016 Report Share Posted April 2, 2016 Hi,I'm attempting to select multiple radio buttons (with the same text), using xpath.The html is like this: <input type="radio" class="site-form-field" name="850_4750" id="850_4750_216808" value="#216808"> <label for="850_4750_216808" class="site-form-label inline">Not applicable</label> This command selects the 1st instance of 'Not applicable' but does not select the rest: plugin command("ExBrowser.dll", "ExBrowser Click", "x://label[contains(text(),\"Not applicable\")]") How should I construct the xpath so that it selects ALL radio buttons marked 'Not applicable' and not just the first one? Quote Link to post Share on other sites
Bot-Factory 602 Posted April 2, 2016 Report Share Posted April 2, 2016 Hi, I'm attempting to select multiple radio buttons (with the same text), using xpath. The html is like this: <input type="radio" class="site-form-field" name="850_4750" id="850_4750_216808" value="#216808"> <label for="850_4750_216808" class="site-form-label inline">Not applicable</label> This command selects the 1st instance of 'Not applicable' but does not select the rest: plugin command("ExBrowser.dll", "ExBrowser Click", "x://label[contains(text(),\"Not applicable\")]") How should I construct the xpath so that it selects ALL radio buttons marked 'Not applicable' and not just the first one? The problem here is not the Xpath. Your Xpath Expression will actually select all the elements correctly.But the ExBrowser Click Command can only click one element at a time. And if the Xpath Expression you use has multiple matches, it will click the first one. So the solution is, you click one at a time. With Xpath Offsets. You learn all that in my Xpath tutorials:http://www.bot-factory.com/xpath-video-tutorials/ But here's a quick tip:(//label[contains(text(),"Not applicable")])[1] Dan 1 Quote Link to post Share on other sites
ILoveUBot 10 Posted April 2, 2016 Author Report Share Posted April 2, 2016 Ahh Thanks Dan! I get it now. It's a few months since I watched the videos. I'll need to watch them again sorry!!! Quote Link to post Share on other sites
uRobot 1 Posted June 30, 2016 Report Share Posted June 30, 2016 @op where you able to do it? I do not mean to jack your thread... but... Dan, Can you please elaborate a little bit more about your tip? i tried it and it only clicks the corresponding number... I also have it on a loop... but then again... the button that keeps getting clicked is the number inside [number_here] I also do not think it is possible to put the [number_here] into a variable and increment it... on each loop... please help... i am running out of hair... been pulling them all day long... Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted June 30, 2016 Report Share Posted June 30, 2016 broad selectorx://label[contains(text(),"Not applicable")] This one selects the first one availablex:(//label[contains(text(),"Not applicable")])[1] This one selects the second one availablex:(//label[contains(text(),"Not applicable")])[2] Note the formatting and the 1 and 2 at the end in brackets and the ( and ) around the main selectorthis is like offsets. but start at 1 Quote Link to post Share on other sites
uRobot 1 Posted July 1, 2016 Report Share Posted July 1, 2016 thanks TJ, I was actually trying to increment that x:(//label[contains(text(),"Not applicable")])[1] For those guys who might need it: here's what I got from Dan: plugin command("ExBrowser.dll", "ExBrowser Click", "x:(//a)[{#counter}]") just set the variable and there it goes... Thanks Dan and Tj Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.