site-packages\selenium\webdriver\support 目录下找到了expected_conditions,这些常用的断言都在expected_conditions.py 文件里面找到,先来看下这个文件下这些类的使用:

title_is验证传入的参数title是否等于driver.title

title_contains(验证传入的参数title是否包含driver.title

presence_of_element_located验证元素是否出现传入的参数都是元组类型的locator

presence_of_all_elements_located验证元素是否出现传入的参数都是元组类型的locator

visibility_of_element_located(验证元素是否可见传入的参数是元组类型的locator
invisibility_of_element_located验证元素是否可见传入的参数是元组类型的locator

visibility_of验证元素是否可见传入的参数是WebElement

text_to_be_present_in_element(判断某段文本是否出现在某元素判断元素的text

text_to_be_present_in_element_value判断某段文本是否出现在某元素判断元素的value

frame_to_be_available_and_switch_to_it断frame是否可切入,可传入locator元组或者直接传入定位方式

alert_is_present(判断是否有alert出现

element_to_be_clickable(判断元素是否可点击,传入locator

element_to_be_selected(判断元素是否被选中传入WebElement对象
element_located_to_be_selected判断元素是否被选中传入locator元组
element_selection_state_to_be判断元素是否被选中传入WebElement对象以及状态,相等返回True,否则返回False

element_located_selection_state_to_be判断元素是否被选中传入locator以及状态,相等返回True,否则返回False

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