Selenium WebDriver 的 isDisplayed() 方法是如何工作的 [英] How does Selenium WebDriver's isDisplayed() method work

查看:34
本文介绍了Selenium WebDriver 的 isDisplayed() 方法是如何工作的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有很多情况需要验证页面(及其所有元素)是否正确显示.WebElement 的 isDisplayed() 方法似乎是执行此操作的合乎逻辑的方法,但是我想准确了解此方法正在执行的操作以确定是否显示"元素.javadoc 没有说明内部该方法的工作原理和网络上的其他信息似乎充其量是稀疏的.

I currently have a large number of circumstances where I need to verify that a page (along with all of its elements) are displaying correctly. The isDisplayed() method of WebElement appears to be a logical way to do this, however I would like to understand precisely what this method is doing to determine whether or not an element "is displayed". The javadoc does not shed any light on the inner workings of the method and other information on the web appears to be sparse at best.

如果有人能详细说明这种方法的工作原理,我将不胜感激.

If anyone could provide a detailed description of how this method works, I would be very grateful.

推荐答案

WebDriver 有自己的 W3C 规范.

WebDriver has its own W3C specification.

关于确定可见性的部分正是您所追求的.

The section about determining visibility is what you are after.

我要警告说,显示"是一个如此宽泛的术语,因此有很多场景.因此,很可能存在 WebDriver 没有考虑到的情况.

I would warn that saying something "is displayed" is such a broad term, and thus there are many scenarios to it. Therefore, there may well be situations that WebDriver does not account for.

因此,至关重要实际上很重要,要记住显示"或可见"的事物具有多种含义.(同样,一个页面完全加载,也有很多含义.)

So it's important, vital in fact, to remember that something being "displayed" or "visible" has many meanings. (In the same way a page being fully loaded, also has many meanings.)

还要记住 Selenium 是完全开源.没有什么能阻止你从重新签出存储库并在本地检查它.

Also remember Selenium is entirely open source. There is nothing stopping you from getting a fresh checkout of the repository and inspecting it locally.

这篇关于Selenium WebDriver 的 isDisplayed() 方法是如何工作的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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