出现nosuchelement的 三个原因:1xpath定位错误,2、网络等待设置错误 3、网页中的跳转
1、强制等待
sleep(等待的最长时间) sleep(5)
2、隐性等待
complicity_wait(等待的最长时间)
3、显性等待
明确等到某个条件满足之后,再去执行下一步操作
WebDriverWait 类:显性等待类
driver = webdriver.Chrome()
WebDriverWait(driver,等待时长,轮循周期).until()/until_not()
expected_conditions 模块 提供一系列期望发生的条件
presence_of_element_located 元素存在
visibility_of_element_located 元素可见
element_to_be_clickable 元素可点击