AttributeError:“ Selenium”对象在Selenium和Python中没有属性“ send_keys”

时间:2018-12-26 12:24:29

标签: python selenium selenium-webdriver webdriver sendkeys

我创建了我的Selenium IDE测试,并将测试导出到Python 2 Remote Control。当我运行脚本时,它给了我这个错误:

[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")

致谢

1 个答案:

答案 0 :(得分:2)

根据Selenium文档,enter image description here不能进行这种调用。我认为,首先需要使用find_element_by_id查找元素对象。然后调用该对象的send_keys

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

(这假设sel是您的Web驱动程序对象。)