1、until
- WebDriverWait(driver,10).until(lambda driver.find_element_by_Id[“kw”]).send_keys(“qlang”)
- WebDriverWait(driver,10).until(EC,presence_of_element_located(By_Id,“kw”))
2、until_not
- WebDriverWait(driver,10).until_not(lambda x: x.find_element_by_id(“kw”).is_dispalyed())
3、expected_conditions(EC)模块各种条件
- title_is 判断当前页面的title是否完全等于(==)预期字符串,返回布尔值
- title_contains 判断当前页面的title是否包含预期字符串,返回布尔值
- presence_of_element_located 判断某个元素是否被加到了dom树里,并不代表该元素一定可见
- visibility_of_element_located 判断某个元素是否可以可见,可见代表元素非隐藏,并且元素的高和款都不等于0
- visibility_of 跟上面的方法做一样的事情,只是上面的方法要传入locator,这个方法直接传定位的element就好了
- presence_of_all_elements_located 判断是否至少有1个元素存在于dom树种,举个例子:如果页面上有n个元素的class都是‘md-3’,那么只要有一个元素存,这个方法就返回true
- text_to_be_present_in_element 判断某个元素中的text是否包含了预期的字符串
- text_to_be_present_in_element_value 判断某个元素中的value属性是否包含了预期的字符串
- frame_to_be_avaliable_and_switch_to_it 判断frame是否可以switch进去,如果可以的话,返回true并且switch进去,否则返回false
- invisibility_of_element_located 判断某个元素是否不存在于dom树或不可见
- element_to_be_clickable 判断某个元素是否可见并是enable的,这样才叫clickable
- staleness_of 等某个元素从dom树移除,返回true 或 false
- element_to_be_selected 判断某个元素是否被选中了,一般用在下拉列表
- element_selection_state_to_be 判断某个元素的选中状态是否符合预期
- element_located_selection_state_to_be 跟上面的方法作用一样,只是上面的方法传入定位到的element,这个方法传入locator
- alert_is_present 判断页面上是否存在alert
4、基础条件
- is_displayed() 判断某个元素是否存在页面上(指HTML代码中是否存在)
- is_enabled()用户存储input,select等元素的可编辑状态
- is_selected()判断某个元素是否被选中