如果文本存在,則點擊xyz
否則點擊abc
。如何查找文本是否存在
我使用下面的if
聲明:
if(driver.findElement(By.xpath("/html/body/div[2]/div/div/div/div/div/div/table/tbody/tr[6]/td[2]")).isDisplayed())
{
driver.findElement(By.linkText("logout")).getAttribute("href");
} else {
driver.findElement(By.xpath("/html/body/div/div/div/a[2]")).click();
}
腳本失敗,出現以下錯誤信息:
Unable to locate element: {"method":"xpath","selector":"/html/body/div[2]/div/div/div/div/div/div/table/tbody/tr[6]/td[2]"}
請提供HTML代碼。 – 2016-11-28 12:46:00