Testing 如何在SeleniumWebDriver中编写If和else函数
我正在尝试编写selenium webdriver脚本,但我不知道如何在selenium webdriver中编写If和else函数。使用脚本中使用的语言的一般语法。 例如,如果您选择在脚本中使用java- 如果(条件) { //身体 } 其他的 { //身体Testing 如何在SeleniumWebDriver中编写If和else函数,testing,selenium-webdriver,Testing,Selenium Webdriver,我正在尝试编写selenium webdriver脚本,但我不知道如何在selenium webdriver中编写If和else函数。使用脚本中使用的语言的一般语法。 例如,如果您选择在脚本中使用java- 如果(条件) { //身体 } 其他的 { //身体 }用60秒的时间搜索你自己的问题并找到答案。 if(driver.findElement(By.xpath("*********")).isDisplayed()) { // Click
}用60秒的时间搜索你自己的问题并找到答案。
if(driver.findElement(By.xpath("*********")).isDisplayed())
{
// Click on Teaching Notes
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
driver.findElement(By.xpath("****")).click();
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
Thread.sleep(4000);
System.out.println(driver.findElement(By.xpath("***")).getText());
System.out.println(driver.getCurrentUrl());
driver.navigate().back();
driver.navigate().back();
}
else
{
System.out.println("No Teaching Notes Present");
driver.navigate().back();
}