QA|selenium在send_keys时报错dict object has no attribute ''|UI自动化测试

发布时间 2023-05-31 14:09:39作者: T-Better

Q:selenium在send_keys时报错dict object has no attribute 'send_keys',如下图

 增加了print(type(e1))发现确实是字典类型,怪了,按道理e1的type应该是selenium.webdriver.remote.webelement.WebElement才对,怎么会变成dict字典呢?

我网上查了,按照(115条消息) Python运行selenium时报错‘dict‘ object has no attribute ‘send_keys‘解决fang‘an_翔空中,策人生的博客-CSDN博客说,肯定不是find_element_by_NAME,因为这个selenium包是我云桌面外的,外面运行正常的!

至于版本:

 

更换成对应版本,更换之后确实可以了

CNPM Binaries Mirror (npmmirror.com)

原因:selenium所用浏览器驱动是python.exe同层的那个,要保持与浏览器版本对应才行

 

解决:换成对应版本浏览器驱动,放到python.exe同层即可