您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

selenium:selenium如何识别可见元素?是否可以将其加载到DOM中但不能在UI上呈现?

selenium:selenium如何识别可见元素?是否可以将其加载到DOM中但不能在UI上呈现?

可以识别 存在能见度 只要它们的元件的 存在可见 HTML DOM 。从用户的角度来看,你可以调用isDisplayed()上的方法 WebElement 如果打算检查 WebElement显示 与否。根据当前的实现, Selenium 可能无法区分 加载 元素和 渲染 元素。 ExpectedConditions 类中的 ElementToBeClickable 方法检查元素是否 可见 设置了期望值 __ __并 启用它, 以便您可以 单击 它。

元素在正在进行的DOM,但UI显示正在加载的加载 你还是要 的 的JavaScriptAJAX调用 ,因此所有完成加载页面 WebElements页面上成为 。在大多数 等待完整的负荷 ,你可以设置pageLoadStrategy到 ,但仍可能诱发 WebDriverWait 于预期 WebElement 成为 可见交互点击

粗略 如果没有加载UI seleniumhq 可能不能够与几个DOM元素的交互。

根据您的反问,这里是 WebElement 的不同阶段以及检查这些阶段的相应 ExpectedConditions

presenceOfElementLocated(By locator)

An expectation for checking that an element is present on the DOM of a page. This does not necessarily mean that the element is visible.

visibilityOf(WebElement element)

An expectation for checking that an element, kNown to be present on the DOM of a page, is visible. Visibility means that the element is not only displayed but also has a height and width that is greater than 0.

元素

elementToBeClickable(By locator)

An expectation for checking an element is visible and enabled such that you can click it.

:根据docs

其他 2022/1/1 18:14:01 有511人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶