我想验证是否选择了WebElement。HTML中此元素存在(当选中时)为:
<span id="user-settings-price-preview-checkbox" class="user-settings-selector-checkbox active"></span>
以及何时未选择:
<span id="user-settings-price-preview-checkbox" class="user-settings-selector-checkbox"></span>
如何使用硒和TestNG进行验证?
要验证是否WebElement
选择了,您可以尝试:
String attr = driver.findElement(By.id("user-settings-price-preview-checkbox")).getAttribute("class");
if(attr.contains("active"))
System.out.println("WebElement selected");
else
System.out.println("WebElement NOT selected");
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句