Python Selenium - AttributeError:WebElement 对象没有属性 sendKeys
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38521136/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python Selenium - AttributeError : WebElement object has no attribute sendKeys
提问by ChrisG29
I'm trying to pass through "ENTER" to a text field, using Selenium
(Python). The text box requires that each phone number be entered on a new line, so it will look something like:
我正在尝试使用Selenium
(Python)将“ENTER”传递到文本字段。文本框要求在新行中输入每个电话号码,因此它看起来像:
#Add the phone number#
Webelement.sendKeys(Keys.ENTER)
I've imported the following library:
我已经导入了以下库:
from selenium.webdriver.common.keys import Keys
The problem I'm getting is that it fails with:
我遇到的问题是它失败了:
AttributeError: 'WebElement' object has no attribute 'sendKeys'
AttributeError: 'WebElement' 对象没有属性 'sendKeys'
Does anyone know how to resolve this? I've been searching for a solution, but haven't been able to find anything.
有谁知道如何解决这个问题?我一直在寻找解决方案,但一直找不到任何东西。
回答by Saurabh Gaur
Try using WebElement::send_keys()
instead of sendKeys
as below :-
尝试使用WebElement::send_keys()
而不是sendKeys
如下:-
from selenium.webdriver.common.keys import Keys
Webelement.send_keys(Keys.ENTER)