java - List<WebElement> for only first 3 columns of the table -
where says findelements(by.xpath("td[]"))
, how td[1]
, td[2]
, td[3]
elements in list
?
webelement webtable = driver.findelement(by.xpath("")); list<webelement> totalrowcount = webtable.findelements(by.xpath("")); int rowindex = 1; (webelement rowelement : totalrowcount) { list<webelement> totalcolumncount = rowelement.findelements(by.xpath("td[]")); int columnindex = 1; (webelement colelement : totalcolumncount) { columnindex = columnindex +1; } rowindex = rowindex + 1; }
you should try using position()
function of xpath
below select first 3 columns each row :-
list<webelement> totalcolumncount = rowelement.findelements(by.xpath("td[position() <= 3]"));
Comments
Post a Comment