我对Selenium相当陌生,并且是自我教学,几年前我使用过JAVA
我想在value1周围添加一条语句,以在值符合预期的情况下执行操作,否则执行另一项操作
driver.findElement(By.id("task-table-filter")).sendKeys("test1");
WebElement firstName = driver.findElement(By.xpath("//*[@id=\"task-table\"]/tbody/tr[8]/td"));
String value = firstName.getText();
System.out.println(value);
driver.findElement(By.xpath("//*[@id=\"task-table-filter\"]")).clear();
driver.findElement(By.id("task-table-filter")).sendKeys("test2");
WebElement searchname = driver.findElement(By.xpath("//*[@id=\"task-table\"]/tbody/tr[6]/td[3]"));
String value1 = searchname.getText();
System.out.println(value1);
答案 0 :(得分:0)
您可以使用简单的if / else
if (value1.equals("expected value")) {
do.action;
} else {
do.otherActon;
}