MR_YINXINYU
MR_YINXINYU
2019-02-26 17:18

selenium webdriver调试报错 Message: Failed to convert data to an object?

1、selenium webdriver调试报错 Message: Failed to convert data to an object

2、代码

coding =utf-8

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import os

browser=webdriver.Firefox() #打开火狐浏览器

browser.maximize_window() #最大化浏览器

browser.implicitly_wait(30) #智能等待时间

browser.get("http://demo.jeesite.com/js/a/login") #访问http://demo.jeesite.com/js/a/login

browser.find_element_by_id("btnSubmit").click() #点击系统管理

browser.find_element_by_link_text("组织管理").click() #点击组织管理

browser.find_element_by_link_text("用户管理").click() #点击用户管理

browser.find_element_by_xpath("//a[contains(text(),'新增')]").click() #点击用户管理界面新增按钮

browser.quit() #关闭浏览器

3、报错信息
C:\Users\yinxinyu\AppData\Local\Programs\Python\Python37\python.exe D:/Work/Project/python/text3.py
Traceback (most recent call last):
File "D:/Work/Project/python/text3.py", line 23, in
browser.find_element_by_xpath("//a[contains(text(),'新增')]").click()
File "C:\Users\yinxinyu\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Users\yinxinyu\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
'value': value})['value']
File "C:\Users\yinxinyu\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\yinxinyu\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Failed to convert data to an object

4、尝试过的办法:更换定位方式class以及Xpath都不行

5、报错截图
图片说明

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

相关推荐