[英]Selenium Webdriver [Java] Dynamic Table: Get the last value of a row (With Conditionals)
我需要将Selenium与动态表配合使用的帮助。
我需要单击状态为“ ACTIVE”的LAST帐户。在该图像中显示了该示例。
我正在尝试下一个代码:
WebElement lastCredit = driver.findElement(By.xpath("(//table[@class='tableinfo']/tbody/tr[last()]/td[3]/a and contains(text(), 'ACTIVE'") );
lastCredit.sendKeys(Keys.ENTER);
我无法单击accound,该程序失败。
我正在尝试使用2 FOR:
WebElement rows = driver.findElement(By.xpath("(//table[@class='tableinfo']/tbody/tr"));
List<WebElement> columns = (List<WebElement>) driver.findElement(By.xpath("(//table[@class='tableinfo']/tbody/tr[1]/td"));
String[] array = new String[4];
for(int i = 0; i <= rows.length; i = i ++)
{
for(int j = 0; j <= columns.length; j = j ++)
{
array[j] = driver.findElement(By.xpath("(//table[@class='tableinfo']/tbody/tr[i]/td[j]/a")).getAttribute("value");
}
if (array[4] == “ACTIVE”) and (array[4].last()); {
array.get(4).click();
}
}
请帮我。
无论图片是什么,如果您的要求是单击最后一个活动状态,请尝试以下简单代码段
List<WebElement> activeColumns = driver.findElements(By.xpath("//td[text()='ACTIVE']"));
activeColumns.get(activeColumns.size()-1).click();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.