zoukankan      html  css  js  c++  java
  • python-web自动化-Python+Selenium之expected_conditions:各种判断

    expected_conditions一般也简称EC

    以下两个条件类验证title,验证传入的参数title是否等于或包含于driver.title
    title_is
    title_contains

    以下两个条件验证元素是否出现,传入的参数都是元组类型的locator,如(By.ID, 'kw')
    顾名思义,一个只要一个符合条件的元素加载出来就通过;另一个必须所有符合条件的元素都加载出来才行
    presence_of_element_located
    presence_of_all_elements_located

    以下三个条件验证元素是否可见,前两个传入参数是元组类型的locator,第三个传入WebElement
    第一个和第三个其实质是一样的
    visibility_of_element_located
    invisibility_of_element_located
    visibility_of

    以下两个条件判断某段文本是否出现在某元素中,一个判断元素的text,一个判断元素的value
    text_to_be_present_in_element
    text_to_be_present_in_element_value

    以下这个条件判断frame是否可切入,可传入locator元组或者直接传入定位方式:id、name、index或WebElement
    frame_to_be_available_and_switch_to_it

    以下这个条件判断是否有alert出现
    alert_is_present

    以下这个条件判断元素是否可点击,传入locator
    element_to_be_clickable

    以下四个条件判断元素是否被选中,第一个条件传入WebElement对象,第二个传入locator元组
    第三个传入WebElement对象以及状态,相等返回True,否则返回False
    第四个传入locator以及状态,相等返回True,否则返回False
    element_to_be_selected
    element_located_to_be_selected
    element_selection_state_to_be
    element_located_selection_state_to_be

    最后一个条件判断一个元素是否仍在DOM中,传入WebElement对象,可以判断页面是否刷新了
    staleness_of

  • 相关阅读:
    Channel使用技巧
    Flask开发技巧之异常处理
    后端开发使用pycharm的技巧
    python单元测试
    Docker入门介绍
    python高阶函数的使用
    python内置模块collections介绍
    python中@property装饰器的使用
    三次握手四次挥手
    python类方法@classmethod与@staticmethod
  • 原文地址:https://www.cnblogs.com/Aphrodite/p/10308499.html
Copyright © 2011-2022 走看看