HTML   发布时间:2022-04-14  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了在Webdriver中提交表单后,如何等待页面加载.我正在使用firefox驱动程序大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试自动化测试用例,我通过单击图像提交表单.

页面重新加载后,我无法与网页上的任何元素进行交互

我正在使用java,firefox驱动程序.

代码卡住了,根本无法识别元素.

有没有像QTP,SELEnium那样的webdriver的等待机制?

解决方法

只需使用 FluentWait级:
/**
 * An implementation of the {@link Wait} interface that may have its timeout
 * and polling interval configured on the fly.
 *
 * <p>Each FluentWait instance defines the maximum amount of time to wait for
 * a condition,as well as the frequency with which to check the condition.
 * Furthermore,the user may configure the wait to ignore specific types of
 * exceptions whilst waiTing,such as
 * {@link org.openqa.SELEnium.NoSucHelementexception NoSucHelementexceptions}
 * when searching for an element on the page.
 *
 * <p>Sample usage:
 * <code><pre>
 *   // WaiTing 30 seconds for an element to be present on the page,checking
 *   // for its presence once every 5 seconds.
 *   Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
 *       .withTimeout(30,SECONDS)
 *       .pollingEvery(5,SECONDS)
 *       .ignoring(NoSucHelementexception.class);
 *
 *   WebElement foo = wait.until(new Function<WebDriver,WebElement>() {
 *     public WebElement apply(WebDriver driver) {
 *       return driver.findElement(By.id("foo"));
 *     }
 *   });
 *

WebDriverWait.

大佬总结

以上是大佬教程为你收集整理的在Webdriver中提交表单后,如何等待页面加载.我正在使用firefox驱动程序全部内容,希望文章能够帮你解决在Webdriver中提交表单后,如何等待页面加载.我正在使用firefox驱动程序所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。