selenium - 隐式等待和 AjaxElementLocatorFactory 有什么区别?
问题描述
根据定义,
隐式等待是告诉 Web Driver 在尝试查找一个或多个元素(如果它们不是立即可用的)时轮询 DOM 一段时间。
请参阅隐式等待
WebElement 的超时将在 AjaxElementLocatorFactory 的帮助下分配给 Object 页面类
从上面看,并不清楚隐式等待和 AjaxElementLocatorFactory 之间究竟有什么区别。请解释。
解决方案
隐式等待
隐式等待是一种配置 WebDriver 在尝试查找元素时轮询 DOM 一段时间的方法,如果它们在HTML DOM中不立即可用。默认设置为0。设置后,将为 WebDriver 对象实例的生命周期设置隐式等待。
您可以在以下位置找到一些相关的讨论:
AjaxElementLocatorFactory
AjaxElementLocatorFactory 是在使用类使用页面工厂时实现服务员的关键优势之一AjaxElementLocatorFactory
。
AjaxElementLocatorFactory基本上是在页面工厂模式中实现的延迟加载概念,仅当 WebElement 用于任何操作时才识别它们,即 WebElement 的timeOut可以在AjaxElementLocatorFactory的帮助下分配给 Object 页面类。
一个例子:
AjaxElementLocatorFactory myFactory = new AjaxElementLocatorFactory(driver, 20); PageFactory.initElements(myFactory, this)
解释:
在上面的代码块中,当对元素执行操作时,等待其可见性仅从那一刻开始。如果在给定的时间间隔内没有找到元素,测试用例执行将抛出
NoSuchElementException
异常。
您可以在如何通过 Selenium 和 Page Factory 实现 AjaxElementLocatorFactory?
推荐阅读
- excel - 如何从一系列单元格中选择一个随机的空单元格,直到选择了范围内的所有单元格?
- docker - 创建一个新的 docker 镜像并捕获外部卷内容
- swift - 记录错误 Jazzy “0% 的文档覆盖率,包含 0 个未记录的符号”
- sql - 古怪更新的定义
- javascript - 未捕获的类型错误:无法读取数组 2d 上未定义的属性“0”
- stdvector - 如何将 xarray 转换为 std::vector?
- java - 带有json数据的AJAX POST请求到spring控制器返回状态405
- android - 将firebase集成到android studio时出错
- flutter - .gradle 文件夹增加每次运行颤振调试
- python - 如何在一张图中绘制 30 个特征的分布并在 python 中按标签区分