栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何继续按selenium填充下一页中的数据?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何继续按selenium填充下一页中的数据?

尝试将隐式等待时间设置为大约10秒,然后再将该元素查找为:-

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);driver.findElement(By.id("Passwd")).sendKeys("yourPassword");driver.findElement(By.id("signIn")).click();

或设置一个明确的等待。显式等待是您定义的代码,用于等待特定条件发生后再继续执行代码。您的情况就是密码输入字段的可见性。

WebDriverWait wait = new WebDriverWait(driver, 10);WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("Passwd")));element.sendKeys("yourPassword");//Now click on sign in button driver.findElement(By.id("signIn")).click();//next page

Explanation: The reason selenium can’t find the element is because the

id
of the password input field is initially
Passwd-hidden
. After you click
on the “Next” button, Google first verifies the email address entered and then
shows the password input field (by changing the id from
Passwd-hidden
to
Passwd
). So, when the password field is still hidden (i.e. Google is still
verifying the email id), your webdriver starts searching for the password
input field with id
Passwd
which is still hidden. And hence, you should wait
until it becomes visible.




转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/568927.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号