Peter_Tester
Peter_Tester

Reputation: 97

Selenium how to get all Xpath's from the page

iam trying to get all object's xpath's from loaded page via selenium

something similar to the funkction that selenium allready have:

selenium.getAllbuttons();

problem is that i cant use this funkction and work with id's because they are all dynamically generated every time when a new page is loaded.

Any ideas how to get all object's xpath's from loaded page?

thank you

Upvotes: 0

Views: 5190

Answers (1)

AutomatedTester
AutomatedTester

Reputation: 22438

you can do

xpathcount = selenium.getXpathCount("//input");
for (i = 0;i<xpathcount;i+=1){
   selenium.click("//input["+i+"]");

}

The above code will click on all the buttons that have input tags and go from the top to the bottom.

The main thing that you want to do is selenium.doSomething("//input["+i+"]"); where doSomething is any Selenium Command.

Upvotes: 1

Related Questions