http://www.testclass.net/selenium_python/mouse-event

定位元素失败,提示

Selenium使用link text定位元素失败,提示no such element: Unable to locate element

 

改成使用通过xpath定位,问题解决

1、打开百度首页,点击F12,如图操作

Selenium使用link text定位元素失败,提示no such element: Unable to locate element

2、右击-Copy-Copy XPath,获得  //*[@id="s-usersetting-top"]

Selenium使用link text定位元素失败,提示no such element: Unable to locate element

3、将获得的XPath内的双引号改成单引号即可

above = driver.find_element_by_xpath("//*[@id='s-usersetting-top']")

Selenium使用link text定位元素失败,提示no such element: Unable to locate element

相关文章: