51Testing软件测试论坛

标题: 用element点击时出现'dict' object has no attribute 'click' [打印本页]

作者: 测试积点老人    时间: 2021-11-15 11:07
标题: 用element点击时出现'dict' object has no attribute 'click'
以下源代码:
  1. import re
  2. import time
  3. from selenium import webdriver
  4. from selenium.webdriver.chrome.service import Service
  5. s = Service(r"D:\ChromeDrive\chromedriver.exe")
  6. driver = webdriver.Chrome(service=s)
  7. driver.get('http://quote.eastmoney.com/center/boardlist.html#concept_board')
  8. GaiNian = re.findall('"><a href="//quote.eastmoney.com/unify/r/90.BK.*?">(.*?)</a>', driver.page_source, re.S)
  9. time.sleep(2)
  10. button=driver.find_element('xpath','//*[@id="main-table_paginate"]/a[2]')
  11. print(button)
  12. button.click()
  13. driver.close()
复制代码
报错信息为:
  1. Traceback (most recent call last):
  2.   File "D:/python_work/py_work/hello_world.py", line 27, in <module>
  3.     button.click()
  4. AttributeError: 'dict' object has no attribute 'click'
复制代码
怎么会这样的?selenium里面删了click吗?

作者: 海海豚    时间: 2021-11-16 10:10
改为driver.find_element_by_xpath试试呢
作者: qqq911    时间: 2021-11-16 11:03
元素定位错了吧




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2