Python Selenium - AttributeError : WebElement object has no attribute sendKeys

喜你入骨 提交于 2020-01-10 02:51:44

问题


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:

#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'

Does anyone know how to resolve this? I've been searching for a solution, but haven't been able to find anything.


回答1:


Try using WebElement::send_keys() instead of sendKeys as below :-

from selenium.webdriver.common.keys import Keys

Webelement.send_keys(Keys.ENTER)


来源:https://stackoverflow.com/questions/38521136/python-selenium-attributeerror-webelement-object-has-no-attribute-sendkeys

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!