Post

1 Star2 Stars3 Stars4 Stars5 Stars
Loading ... Loading ...

By Rafaela Azevedo
Hi guys, I’m very occupied in the last months, but I will post a text about catch the lines and values in some table with Webdriver (selenium) in language java. Yes, I am changing a little the subjects, this time I will help the testers, who do automation of sites.
It’s easy if you use XPath.
This table:

Apples
44%

Bananas
23%

Oranges
13%

Other
10%

/html/body/div[1]/div/div[4]/div[2]/div[2]/table/tbody/tr[1]
You catched the first line.
If you want catch the second line, just change the number:
/html/body/div[1]/div/div[4]/div[2]/div[2]/table/tbody/tr[2]
It’s more easy than you expected, not ?
if you want catch all the text of all lines, just write the code:
WebElement listatable = driver.findElement(By.className(“reference”));
for (int i = 0; i < listatable.getLength(); i++) { WebElement line = driver.findElement(By.xpath(“/html/body/div[1]/div/div[4]/div[2]/div[2]/table/tbody/tr[" + i + "]“)); line.getText(); } Fine, now you can catch the text of each line in this table ! I hope has helped the initial testers in something. Bye bye !

Source: http://azevedorafaela.wordpress.com/2012/12/11/how-we-can-find-a-line-in-some-table-with-webdriver-selenium/

Category: Programming, QA, Test and Automation Stuffs, automation, find lines, java, selenium, testers automation, webdriver, xpath

Você também pode querer ler

Comments are off for this post.