如何使用 selenium Webdriver 获取 gmail 的密码输入字段 ID? [英] How to get password input field ID of gmail wiht selenium Webdriver?

查看:28
本文介绍了如何使用 selenium Webdriver 获取 gmail 的密码输入字段 ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://mail.google.com 新的 JS 启用页面获取 ID 遇到麻烦密码输入字段.但是,我已经从电子邮件 ID 页面导航到其 ID - identifierID .

The new JS enabled page of http://mail.google.com is making trouble to get ID of password input field. However, I've navigated from email ID page with its ID - identifierID .

帮我获取密码字段的ID.

Help me to get ID of password field.

提前致谢...

推荐答案

请找到更新的代码:

代码:

    driver.manage().window().maximize();
    driver.get("http://www.gmail.c‌​om"); 
    WebElement elementid = driver.findElement(By.id("identifierId")); 
    elementid.sendKeys(""); 
    WebElement elementnxt = driver.findElement(By.id("identifierNext")); 
    elementnxt.click();
    WebDriverWait wait = new WebDriverWait(driver, 100);
    wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//input[@type='password']")));
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@type='password']")));
    WebElement elementpwd = driver.findElement(By.xpath("//input[@type='password']"));
    elementpwd.sendKeys("123");

我已经验证过了.如果这不起作用,请告诉我.

I have validated it on my end. Let me know if this doesn't work.

这篇关于如何使用 selenium Webdriver 获取 gmail 的密码输入字段 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆