Reputation: 123
I want a selenium RC java test script that prints all the links in a page which contains show/id
.
I tried this
int servicecount= selenium.getXpathCount("xpath=//a[contains(@href,'show/id')]").intValue();
for(int servicecnt=1;servicecnt<=servicecount;servicecnt++)
{
String some_container=selenium.getText("xpath= //a[contains(@href,'show/id')["+servicecnt+"]");
System.out.println(some_container);
}
This doesn't work. Please suggest solutions.
Upvotes: 1
Views: 883
Reputation: 38424
As said in the spec,
NOTE: The location path
//para[1]
does not mean the same as the location path/descendant::para[1]
. The latter selects the first descendantpara
element; the former selects all descendantpara
elements that are the firstpara
children of their parents.
That means that you need to use the latter approach:
selenium.getText("xpath=/descendant::input[contains(@href,'show/id')]["+servicecnt+"]");
Upvotes: 1