selenium—显示等待中期望的场景语句

① alert_is_present()

    判断页面是否出现alert框

wait = WebDriverWait(driver,10)
alert = wait.until(EC.alert_is_present())
print alert.text

 

②wait.until(EC.element_located_selection_state_to_be(locator,state)

  判断元素选中状态是否符合预期,True为选中,False为未选中

wait = WebDriverWait(driver,10)
wait.until(EC.element_located_selection_state_to_be((By.ID, "peach"), True))

 

③ element_located_to_be_selected()

 期望元素处于选中状态

wait = WebDriverWait(driver,10)
wait.until(EC.element_located_to_be_selected((By.ID, "xxx")))
wait.until(EC.element_located_to_be_selected(driver.find_element_by_id("xxx")))

 

④ element_to_be_clickable()

  判断元素是否可见并能被单击

wait = WebDriverWait(driver,10)
wait.until(EC.element_to_be_clickable(By.ID, "xxx"))

 

 ⑤ text

text_to_be_present_in_element(locator,text)  判断内容text是否出现在元素中

   text_to_be_present_in_element(By.xxx,"xxx")

text_to_be_present_in_element_value(locator,text)  判断text是否出现在元素的value属性中

  text_to_be_present_in_element_value((By.xxx,"xxx"), "valuexxx")

 

 

 

 

 

 

 

你可能感兴趣的:(selenium—显示等待中期望的场景语句)