selenium中提示错误:
selenium.common.exceptions.WebDriverException: Message: unknown error: Element <a href="#" class="prefpanelgo">...</a> is not clickable at point (580, 207). Other element would receive
以及:
selenium.common.exceptions.NoAlertPresentException: Message: no such alert
搞了半天,没明白哪里没有定位出来。难道是定位元素的方法写错了?元素属性是动态的?然后发现并不是。
想起来,中午刚学过:可能是网页加载是异步的,导致有些节点还没有加载出来,但是代码已经在运行,所以在定位保存设置之前,先代码睡一会,所以有了以下的改进版:
# coding:utf-8
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from time import sleep
import time
driver