您的位置:首页 > 其它

selenium 元素等待

2016-01-28 11:12 381 查看
利用这个类就可以实现智能等待的效果:

wait = WebDriverWait(webdriver.chrome(),30)

  elm = wait.until(lambda x: x.find_element_by_xpath(Xpath))

  elm.click()

再提供一个判断元素存在否:

  def isPresent(self):

  try: driver.find_element_by_xpath(Xpath)

  except NoSuchElementException, e: return False

  return True
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: