在site-packages\selenium\webdriver\support 目录下找到了expected_conditions,这些常用的断言都在.py 文件里面找到,先来看下这个文件下这些类的使用:expected_conditions
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对象,可以判断页面是否刷新了)
原文:http://12965114.blog.51cto.com/12955114/1930587