使用硒登录Gmail

时间:2018-12-03 16:16:27

标签: selenium

我的代码无法找到密码元素。密码字段出现类似“找不到元素”之类的错误。请帮助

public static void main(String[] args) {
    System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir")+"\\chromedriver.exe");
    WebDriver driver = new ChromeDriver();
    driver.get("https://google.com");       
    driver.findElement(By.xpath("//a[text()='Gmail']")).click();
    driver.findElement(By.xpath("//a[text()='Sign In']")).click();
    driver.findElement(By.xpath("//*[@id=\"identifierId\"]")).sendKeys("abc@gmail.com");
    driver.findElement(By.xpath("//*[@id=\"identifierNext\"]/content/span")).click();
    driver.findElement(By.xpath("//*[@id=\"password\"]/div[1]")).sendKeys("1234");      
    driver.findElement(By.xpath("//*[@id=\"password\"]/div[1]/div/div[1]/input")).click();

}

0 个答案:

没有答案
相关问题