selenium python学习笔记---添加等待时间

时间:2015-02-16 08:57:09   收藏:0   阅读:3614

有时候为了保证脚步运行的稳定性,需要在脚本中添加等待时间

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

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

ele.click()

 

判断元素存在与否:

def isPresent(self):

  try:

    driver.find_element_by_xpath(Xpath)

  excep NoSuchElementException,e:

    return False

  else:

    return True

原文:http://www.cnblogs.com/saryli/p/4293670.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!