RE: How to get list of items and then get a specific item in each itemlist?

I  am new to selenium.I have to get list of items which i got through findElements but then I need to get a specefic item  e.g get 3,4,5 item from each itemlist.
I tried to use for loop but it did not work.

String sText = uiItem.findElement(By.xpath(“//*[@id=’shoe_list’]/li[“+i+”]/div/table/tbody/tr[4]/td[2]”)).getText();

Please help.

SeleniumTesing Default Asked on November 20, 2014 in Selenium WebDriver.
Add Comment
1 Answers

Hi

All Those Elements Must be Differing with Some Index so try Parametrizing The Method That is Getting Text
Something like That
for(some values of i)
{
String sText = uiItem.findElement(By.xpath(“//*[@id=’shoe_list’]/li[“+i+”]/div/table/tbody/tr[4]/td[“”+i+”]”)).getText(); // suppose this is the index that is differing

if(sText.equals(“text u need”)){
return sText;
}else{
i++
}
}

Something like that Should Work i guess…if it Dont Please Post More Info about your problem

Regards
Ankit

Vice Professor Answered on November 21, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.