selenium ExpectedConditions常用方法

2018-07-27  本文已影响0人  majianping

Expected Conditions的使用场景有两种  1、直接在断言中使用  2、与WebDriverWait配合使用,动态等待页面上元素出现或者消失


1、titleIs(String title):判断当前页面的title是否精确等于预期;

2、titleContains(String title):判断当前页面的title是否包含预期字符串;

3、presenceOfElementLocated(By locator):判断某个元素是否被加到了dom树里,并不代表该元素一定可见;

4、visibilityOfElementLocated(By locator):判断某个元素是否可见(代表元素非隐藏,元素的宽和高都不等于0);

5、invisibilityOfElementLocated(By locator):判断某个元素中是否不存在于dom树或不可见;

6、textToBePresentInElement(By locator, String text):判断某个元素中的text是否包含了预期的字符串;

7、textToBePresentInElementValue(By locator, String text):判断某个元素中的value属性是否包含了预期的字符串;

8、elementToBeClickable(By locator):判断某个元素中是否可见并且是enable的,这样的话才叫clickable;

9、elementToBeSelected(By locator):判断某个元素是否被选中了,一般用在下拉列表;

10、alertIsPresent():判断页面上是否存在alert;

上一篇下一篇

猜你喜欢

热点阅读