问题遇到的现象和发生背景
AttributeError: ‘NoneType’ object has no attribute ‘click’ 错误
用代码块功能插入代码,请勿粘贴截图
这是我的代码
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
myusername = "" # 登录账号
mypassword = "" # 登录密码
driver = webdriver.Edge() # 模拟浏览器打开网站,这里是谷歌浏览器
driver.get("http://xg.hnsoftedu.com") # 网址输入
driver.maximize_window() # 将窗口最大化
time.sleep(10) # 延时加载
driver.find_element_by_xpath("/html/body/header/div[2]/div/div/div[3]/button").click()
driver.find_element_by_xpath("/html/body/div[2]/div[2]/form[1]/h6[1]/input").send_keys("myusername") # 自动输入账号
driver.find_element_by_xpath("/html/body/div[2]/div[2]/form[1]/h6[2]/input").send_keys("mypassword") # 自动输入密码
time.sleep(3)
driver.find_element_by_xpath("/html/body/div[2]/div[2]/form[1]/div/input[1]").click()#点击登录
time.sleep(3)
driver.find_element_by_xpath("/html/body/div[1]/div[4]/div/section/section/div/a/div[2]/p").click()#点击对应的打卡
time.sleep(3)
driver.find_element_by_xpath("saveBtn").click()#点击提交
运行结果及报错内容
Traceback (most recent call last):
File "C:\Users\15003\PycharmProjects\pythonProject$$.py", line 13, in
driver.find_element_by_xpath("/html/body/header/div[2]/div/div/div[3]/button").click()
AttributeError: 'NoneType' object has no attribute 'click'
我想要达到的结果
求解