Selenium webdriver 在gmail中找不到密码字段。获取错误“;webdriver例外情况";

Selenium webdriver 在gmail中找不到密码字段。获取错误“;webdriver例外情况";,selenium-webdriver,Selenium Webdriver,脚本执行速度和页面加载时间不同步,请尝试使用 页面加载超时 import java.util.concurrent.TimeUnit; import org.testng.annotations.*; import static org.testng.Assert.*; import org.openqa.selenium.*; import org.openqa.selenium.chrome.ChromeDriver; public clas

脚本执行速度和页面加载时间不同步,请尝试使用 页面加载超时

    import java.util.concurrent.TimeUnit;
    import org.testng.annotations.*;
    import static org.testng.Assert.*;
    import org.openqa.selenium.*;
    import org.openqa.selenium.chrome.ChromeDriver;

    public class Withtestng {
      private WebDriver driver;

      private boolean acceptNextAlert = true;
      private StringBuffer verificationErrors = new StringBuffer();

      @BeforeClass(alwaysRun = true)
      public void setUp() throws Exception {
         System.setProperty("webdriver.gecko.driver", "/usr/bin/geckodriver");
         System.setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver");
        driver = new ChromeDriver();
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
      }

      @Test
      public void testGmailLogInHtml() throws Exception {
        driver.get("https://www.google.com/");
        driver.findElement(By.linkText("Gmail")).click();
        driver.findElement(By.xpath("/html/body/nav/div/a[2]")).click();
        driver.findElement(By.id("identifierId")).click();
        driver.findElement(By.id("identifierId")).clear();
        driver.findElement(By.id("identifierId")).sendKeys("xyz@gmail.com");


 driver.findElement(By.xpath("//div[@id='identifierNext']/content")).click();

driver.findElement(By.xpath("//input[@class='whsOnd zHQkBf']")).click();
driver.findElement(By.xpath("//input[@class='whsOnd zHQkBf']")).clear();
driver.findElement(By.xpath("//input[@class='whsOndzHQkBf']")).sendKeys("xyz");***
            driver.findElement(By.xpath("//div[@id='passwordNext']/content/span"))click();
            driver.findElement(By.xpath("//div[@id='gb']/div/div/div[2]/div[5]/div/a/span")).click();
driver.findElement(By.id("gb_71")).click();
          }


您可以等待特定条件变为真(即使用wait.until等待元素出现),然后对其执行操作。

请发布完整的Stacktrace。org.openqa.selenium.WebDriverException的可能重复项异常:未知错误:元素在点(451427)处不可单击。其他元素将收到点击:(会话信息:chrome=66.0.3359.181)(驱动程序信息:chromedriver=2.35.528139(47ead77cb35ad2a9a83248b292151462a66cd881),平台=Linux 4.13.0-43-generic x86_64)(警告:服务器未提供任何堆栈跟踪信息)命令持续时间或超时:0毫秒构建信息:版本:“3.12.0”,修订版:“7c6e0b3”,时间:“2018-05-08T15:15:03.216Z”
driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);//