selenium定位css时报org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"

推测原因如下,请进行排查:
原因1:xpath指定位置处还未展现出来,自动化已经进行点击,从而找不到该元素,解决办法就是加入等待时间,thread.sleep(3000);以上为3秒。
原因2:xpath指定位置受前后的影响,比如需要先点击一下其他内容,才能展现,所以需要处理。
建议:
xpath定位建议使用相对路径定位,你使用的绝对路径定位。
原因3:(python+selenium+foxdriver)在报错前一行加
for handle in driver.window_handles:#方法二,始终获得当前最后的窗口
driver.switch_to_window(handle)
原文地址:https://www.cnblogs.com/RENQIWEI1995/p/7998325.html