pra*_*231 1 java selenium selenium-webdriver
我能够编写脚本以将我的电子邮件地址添加到email元素中。但是一旦通过脚本单击“下一步”,Google就会使用ajax将该电子邮件元素动态替换为password元素。这是我遇到的问题,无法在该元素中提供密码并且无法登录。
网址:https://accounts.google.com/signin/v2/identifier?flowName = GlifWebSignIn&flowEntry = ServiceLogin
请编写硒测试脚本以实现此目的。
这是https://accounts.google.com/signin
使用您的有效凭据访问url 登录并Page Title
在控制台上打印的代码块:
String url = "https://accounts.google.com/signin";
driver.get(url);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
WebElement email_phone = driver.findElement(By.xpath("//input[@id='identifierId']"));
email_phone.sendKeys("your_email");
driver.findElement(By.id("identifierNext")).click();
WebElement password = driver.findElement(By.xpath("//input[@name='password']"));
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.elementToBeClickable(password));
password.sendKeys("your_password");
driver.findElement(By.id("passwordNext")).click();
System.out.println(driver.getTitle());
driver.quit();
Run Code Online (Sandbox Code Playgroud)
控制台输出:
Google Accounts
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4746 次 |
最近记录: |