【问题标题】:Python Selenium - AttributeError : WebElement object has no attribute sendKeysPython Selenium - AttributeError:WebElement 对象没有属性 sendKeys
【发布时间】:2016-11-26 01:03:21
【问题描述】:

我正在尝试使用 Selenium (Python) 将“ENTER”传递到文本字段。文本框要求在新行中输入每个电话号码,因此它看起来像:

#Add the phone number#
Webelement.sendKeys(Keys.ENTER)

我已经导入了以下库:

from selenium.webdriver.common.keys import Keys

我遇到的问题是它失败了:

AttributeError: 'WebElement' 对象没有属性 'sendKeys'

有谁知道如何解决这个问题?我一直在寻找解决方案,但找不到任何东西。

【问题讨论】:

  • selenium 文档中的第一个示例应该会有所帮助。此外,谷歌搜索python selenium sendkeys 提供了有关问题的各种有用提示...

标签: python selenium selenium-webdriver sendkeys


【解决方案1】:

尝试使用WebElement::send_keys() 而不是sendKeys,如下所示:-

from selenium.webdriver.common.keys import Keys

Webelement.send_keys(Keys.ENTER)

【讨论】:

  • 我认为应该是WebElement.send_keys() insted of WebElement::send_keys()
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-07-21
  • 2012-10-06
  • 1970-01-01
  • 1970-01-01
  • 2022-06-27
  • 1970-01-01
相关资源
最近更新 更多