测试积点老人 发表于 2021-11-15 11:07:02

用element点击时出现'dict' object has no attribute 'click'

以下源代码:
import re
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
s = Service(r"D:\ChromeDrive\chromedriver.exe")
driver = webdriver.Chrome(service=s)
driver.get('http://quote.eastmoney.com/center/boardlist.html#concept_board')
GaiNian = re.findall('"><a href="//quote.eastmoney.com/unify/r/90.BK.*?">(.*?)</a>', driver.page_source, re.S)
time.sleep(2)
button=driver.find_element('xpath','//*[@id="main-table_paginate"]/a')
print(button)
button.click()
driver.close()报错信息为:
Traceback (most recent call last):
File "D:/python_work/py_work/hello_world.py", line 27, in <module>
    button.click()
AttributeError: 'dict' object has no attribute 'click'怎么会这样的?selenium里面删了click吗?

海海豚 发表于 2021-11-16 10:10:39

改为driver.find_element_by_xpath试试呢

qqq911 发表于 2021-11-16 11:03:16

元素定位错了吧
页: [1]
查看完整版本: 用element点击时出现'dict' object has no attribute 'click'