【问题标题】:AttributeError: 'selenium' object has no attribute 'send_keys' with Selenium and PythonAttributeError: 'selenium' 对象在 Selenium 和 Python 中没有属性 'send_keys'
【发布时间】:2018-12-26 12:24:28
【问题描述】:

我创建了我的 selenium IDE 测试,我将测试导出到 Python 2 远程控制。当我运行脚本时,它给了我这个错误:

[root@localhost python]# ./check_selenium.py -s pruebas -w 40 -c 60
SELENIUM UNKNOWN FAIL: not all tests passed -> pruebas  | E
======================================================================
ERROR: test (__main__.test)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pruebas", line 21, in
    sel.send_keys("id=buscador", "3")
AttributeError: 'selenium' object has no attribute 'send_keys'

----------------------------------------------------------------------
Ran 1 test in 59.428s

遥控器不能用按键吗?

这是我的台词:

 sel.send_keys("id=buscador", "3")

问候

【问题讨论】:

  • 代码在哪里?
  • 你有一个最小的、完整的、可验证的例子吗?我不知道你是如何定义 sel 变量的。

标签: python selenium selenium-webdriver webdriver sendkeys


【解决方案1】:

根据 Selenium 文档,send_keys 不提供这种调用。我认为,您首先需要找到带有find_element_by_id 的元素对象。然后调用该对象的send_keys

sel.find_element_by_id("buscadorReferencia_widget").send_keys("8090393")

(假设sel 是您的网络驱动程序对象。)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-21
    • 2022-06-27
    相关资源
    最近更新 更多