driver.findElement(By.id("btnSendMailCopy")).click();
Thread.sleep(3000);
if(driver.findElement(By.xpath("/html/body/section[1]/div/article/nav/button[2]")).isDisplayed())
{
driver.findElement(By.xpath("/html/body/section[1]/div/article/nav/button[2]")).click();
System.out.println("clicked");
}
else if(driver.findElement(By.id("VendorCardHolderName")).isDisplayed())
{
Select dropdown = new Select(driver.findElement(By.id("VendorTinCardType")));
dropdown.selectByVisibleText("VISA");
driver.findElement(By.id("VendorCardHolderName")).sendKeys("TestName");
在不使用 if else 的情况下,我能够成功运行脚本,但是当我想运行 else 部分时,它显示错误为
无法定位元素:{"method":"xpath","selector":"/html/body/section[1]/div/article/nav/button[2]"}