selenium.common.exceptions.NoSuchFrameException: Message: no such frame

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element

错误原因: 所在的框架不对 导致找不到元素

https://www.cnblogs.com/technologylife/p/5851496.html

解决方法: 1. 先回到最外层框架 2.进入要定位元素的框架 3.定位

代码:

driver.switch_to.default_content()	#回到主框架
driver.switch_to.frame("myframe")	#进入要定位元素被包含的那层框架,框架可以用id和name直接定位
driver.find_element_by_xpath('xxx')	#用xpath定位

 

你可能感兴趣的:(python)