zoukankan      html  css  js  c++  java
  • ExpectedConditions API

    使用

        public boolean isPresent(String xpath, int waitingTimeInSec) {
            try {
                WebDriverWait wait = new WebDriverWait(webDriver, waitingTimeInSec);
                wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(xpath)));
            } catch (NoSuchElementException e) {
                return false;
            }
            return true;
        }
    

    文档

    方法名 功能
    titleIs( String title) 判断当前页面的title是否精确等于预期
    titleContains( String title) 判断当前页面的title是否包含预期字符串
    urlToBe( String url) 判断当前页面的url是否精确等于预期
    urlContains( String fraction) 判断当前页面的url是否包含预期字符串
    urlMatches( String regex) 字符串正则表达式
    presenceOfElementLocated( By locator) 判断元素是否出现,只要有一个元素出现,就通过。(代表在不代表可见)判断是否至少有 1 个元素存在于 dom 树中。举个例子,如果页面上有 n 个元素的 class 都是’column-md-3’,那么只要有 1 个元素存在,这个方法就返回 True。
    presenceOfElementsLocated( By locator) 判断元素是否出现,必须所有符合条件的元素都加载出来,才通过。
    elementIfVisible(WebElement element) 如果给定元素是可见的且具有非零大小,否则为null
    presenceOfAllElementsLocatedBy( By locator) 判断元素是否出现。
    visibilityOfElementLocated( By locator) 传入类型为:locator 判断某个元素是否可见. 可见代表元素非隐藏,并且元素宽和高都不等于
    visibilityOfAllElementsLocatedBy( By locator) 判断某组元素是否可见
    visibilityOfAllElements(final List elements) 传入类型为:element 判断某个元素是否可见. 可见代表元素非隐藏,并且元素宽和高都不等于
    textToBePresentInElement( WebElement element, String text) 判断某个元素中的text是否包含了预期的字符串;
    textToBePresentInElement(By locator, String text) 判断某个元素中的 text 是否 包含 了预期的字符串
    textToBePresentInElementLocated(final By locator, final String text) 判断某个元素中的 text 是否 包含 了预期的字符串
    textToBePresentInElementValue( WebElement element, String text) 判断某个元素中的 value 属性是否包含 了预期的字符串
    textToBePresentInElementValue(final By locator, final String text) 判断某个元素中的 value 属性是否包含 了预期的字符串
    frameToBeAvailableAndSwitchToIt(final String frameLocator) 断该 frame 是否可以 switch进去,如果可以的话,返回 True 并且 switch 进去,否则返回 False
    frameToBeAvailableAndSwitchToIt(final By locator) 断该 frame 是否可以 switch进去,如果可以的话,返回 True 并且 switch 进去,否则返回 False
    invisibilityOfElementLocated(final By locator) 某个元素中是否不存在于dom树或不可见;
    invisibilityOfElementWithText(final By locator, final String text) 判断带有文本的元素要么不可见,要么文本不存在于元素上
    elementToBeClickable(final By locator) 判断某个元素中是否可见并且是enable的,这样的话才叫clickable;
    elementToBeClickable(final WebElement element) 判断某个元素中是否可见并且是enable的,这样的话才叫clickable;
    stalenessOf(final WebElement element) 判断一个元素是否仍在DOM中,传入WebElement对象,可以判断页面是 否刷新了。
    refreshed(final ExpectedCondition condition)
    elementToBeSelected(WebElement element) 页面元素处于被选中状态
    elementSelectionStateToBe( WebElement element, boolean selected) 判断某个元素的选中状态是否符合预期,传入element
    elementToBeSelected(By locator) 判断某个元素是否被选中了,一般用在下拉列表;
    elementSelectionStateToBe(final By locator, final boolean selected) 判断某个元素的选中状态是否符合预期,传入locator
    alertIsPresent() 判断页面上是否存在alert。
    not(final ExpectedCondition<?> condition)
    WebElement findElement(By by, WebDriver driver)
    List findElements(By by, WebDriver driver)
    isElementPresent(By.id("xxx")

    Refer

    https://blog.csdn.net/kuangjuelian229/article/details/89426477

  • 相关阅读:
    ThinkPHP 中 where条件 or,and 同时使用
    mysql客户端 navicat 本地导入sql文件出错
    mysql查询出所有重复的记录
    JS返回上一页并刷新
    Jquery计算指定日期加上多少天、加多少月、加多少年的日期
    JS获取当前完整的url地址以及参数的方法
    PHP 计算两个时间戳之间相差的时间
    mysql左连接右连接(查询两张表不同的数据)
    C++中的C
    C++编程思想
  • 原文地址:https://www.cnblogs.com/liehen2046/p/11820776.html
Copyright © 2011-2022 走看看