Python+selenium:NoSuchElementException 报错

通过xpath定位元素 find_element_by_xpath
运行时报错:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {“method”:“xpath”,“selector”:"/html/body/ph-root/ph-home/ph-projects/xxx]"}

  • 原因1

xpath提取语句有问题,没有找到对应元素。

  • 原因2

页面没有加载出来。

多次检查xpath提取语句没有问题。属于页面没有加载出来的问题,在提取元素前增加了time.sleep(5),停留5s等待页面加载完成后进行定为元素。

猜你喜欢

转载自blog.csdn.net/sinat_37960022/article/details/113857890