java 检查元素是否使用硒禁用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36396288/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Check if element is disable using selenium
提问by david hol
So i have this WebElement
(now in disable mode):
所以我有这个WebElement
(现在处于禁用模式):
<select id="id1" name="name" disabled=""><option value="">Select...</option>
<option value="false">No</option>
<option value="true">Yes</option></select>
Not disable:
不禁用:
<select id="id1" name="name" ><option value="">Select...</option>
<option value="false">No</option>
<option value="true">Yes</option></select>
So my question is how to check if this element is disable or not ?
所以我的问题是如何检查这个元素是否被禁用?
采纳答案by Sadik Ali
You should use isDisplayed method of WebElement.
您应该使用 WebElement 的 isDisplayed 方法。
WebElement el = driver.findElement(By.id("id1"));
el.isDisplayed ()
回答by kumar
u can use isEnabled() to verify whether it is enabled or disable.it returns boolean .if it returns true the element is enabled if it returns false the element is disabled.
你可以使用 isEnabled() 来验证它是启用还是禁用。它返回布尔值。如果它返回 true 元素被启用,如果它返回 false 元素被禁用。