Selenium 的 WebDriver API 的 chromedriver.exe Chrome 驱动程序中有一个错误。您不能将 send_keys 用于某些类型的输入,例如 jQuery 插件“ EZPZ Hint
”。它适用于简单的表格。
现在,我将使用 Firefox 和 IE 而不是 Chrome 来进行测试,但我希望看到这个问题得到解决。有谁知道允许我使用 Chrome 而不是切换浏览器的不同解决方法?
这里的输入必须使用图像,因为它是动态生成的,我无法从 Chrome 的检查器中复制/粘贴。
我正在使用 Chrome 最新稳定版(14.0.835.202)和一个带有 unittest 类和鼻子作为测试运行器的 Python 脚本。
这是调试信息:
> Traceback (most recent call last): File
> "\\server\QA\Automation\COMMON\product\common.py", line 35, in setUp
> self.web.find_element_by_name("ezpz_hint_dummy_input").send_keys(self.user)
> File
> "C:\Python27\lib\site-packages\selenium-2.8.1-py2.7.egg\selenium\webdriver\remote\webelement.
> py", line 146, in send_keys
> self._execute(Command.SEND_KEYS_TO_ELEMENT, {'value': typing}) File
> "C:\Python27\lib\site-packages\selenium-2.8.1-py2.7.egg\selenium\webdriver\remote\webelement.
> py", line 194, in _execute
> return self._parent.execute(command, params) File "C:\Python27\lib\site-packages\selenium-2.8.1-py2.7.egg\selenium\webdriver\remote\webdriver.p
> y", line 144, in execute
> self.error_handler.check_response(response) File "C:\Python27\lib\site-packages\selenium-2.8.1-py2.7.egg\selenium\webdriver\remote\errorhandle
> r.py", line 118, in check_response
> raise exception_class(message, screen, stacktrace) WebDriverException: Message: 'Message: u\'focusElement execution
> failed;\\n Failed to send keys beca use cannot focus element\'
> \n-------------------- >> begin captured logging <<
> --------------------\ nselenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:51178/session {"sessionId ": null,
> "desiredCapabilities": {"platform": "ANY", "browserName": "chrome",
> "version": "", "javascr iptEnabled":
> true}}\nselenium.webdriver.remote.remote_connection: DEBUG: POST
> http://127.0.0.1:51178 /session/c85bcae35e0f07e805ea80c47ed9b75d/url
> {"url": "http://10.0.20.61/product", "sessionId": "c85bc
> ae35e0f07e805ea80c47ed9b75d"}\nselenium.webdriver.remote.remote_connection:
> DEBUG: POST http://127.0
> .0.1:51178/session/c85bcae35e0f07e805ea80c47ed9b75d/element {"using":
> "name", "sessionId": "c85bcae3 5e0f07e805ea80c47ed9b75d", "value":
> "ezpz_hint_dummy_input"}\nselenium.webdriver.remote.remote_conne
> ction: DEBUG: POST
> http://127.0.0.1:51178/session/c85bcae35e0f07e805ea80c47ed9b75d/element/:wdc:1319 220710066/value {"sessionId": "c85bcae35e0f07e805ea80c47ed9b75d",
> "id": ":wdc:1319220710066", "value ": ["send keys stuff here,
> redacted"]}\n--------------------- >> end captured logging <<