有多个具有相同xpath的String元素。我有使用List<WebElement>
机制的页面对象模型中的商店元素。在我的测试用例中,我想打印列表的最后一个字符串值。如何在Selenium中打印List Array的最后一个字符串值?
下面是存储在存储库中的元素的代码。
public Collection<WebElement> UpdatedMessageList(){
Collection<WebElement> element=driver.findElements(By.xpath("//p[@class='msg-paragraph-panel msg-paragraph-msg ng-binding']"));
return element;
}
任何人都可以帮助我从我的测试用例打印最后一个字符串值吗?
列表使用从零开始的索引。 – Mureinik