tags:

views:

1031

answers:

1

Hi all, 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

+1  A: 

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.

AutomatedTester
first of all thank you for quick answeryour code is nice and helpfull but my problem is not to locate all xpath's but write them down to the file or screen. with your piece of code i can easily find all of xpath's of all object (actually its not good enaugh because it will find them all and i really dont need every xpath for every div etc... but that i will figure out later how to extract only xpath's for object's that i need e.g. buttons fields combo boxes etc.)
Peter_Tester
if its possible please write me here a piece of code that will write one xpath for example to the screen or file, thank you
Peter_Tester
in c# use the Console.Writeline or with Java it would be System.out.println with the xpath.The code that I put above would only give you items that have the input tag e.g <input .... />. it wouldnt give you divs or that.
AutomatedTester
thank you very much !!!
Peter_Tester