Skip to content
This repository has been archived by the owner. It is now read-only.

:: Failed to send keys because cannot focus element in Chrome :: #2328

Closed
lukeis opened this issue Mar 3, 2016 · 9 comments
Closed

:: Failed to send keys because cannot focus element in Chrome :: #2328

lukeis opened this issue Mar 3, 2016 · 9 comments

Comments

@lukeis
Copy link
Member

@lukeis lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 2328

Hi,

When i trying to inssert a vlue in a textbox using the sendkeys for the Chrome webdriver
it's giving an exception saying that 
"Failed to send keys because cannot focus element"

What steps will reproduce the problem?

ChromeDriver theDriver = new ChromeDriver();

 theDriver.Navigate().GoToUrl("https://secure.tesco.com/register/?from=http://www.tesco.com/groceries/%3fanonLogin=true%26vCount=1");

IWebElement theElement = theDriver.FindElementById("loginID");
theElement.SendKeys("Test");


What is the expected output? What do you see instead?
The expected output is it should insert the value in the textbox.

Selenium version: selenium-dotnet-2.4.1
OS: XP
Browser: Chrome
Brower version: 13.0.782.215 m

Exception Details:--

System.InvalidOperationException: Failed to send keys because cannot focus element.
   at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(DriverCommand driverCommandToExecute,
Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebDriver.InternalExecute(DriverCommand driverCommandToExecute,
Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebElement.Execute(DriverCommand commandToExecute,
Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebElement.SendKeys(String text)

Reported by alladi.sai on 2011-08-24 04:20:09

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 3, 2016

Still persist in chromedriver-16

Reported by barancev on 2011-10-13 08:29:51

  • Labels added: Component-WebDriver, Browser-Chrome

Loading

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 3, 2016

Yep, I'm having the same issue. There's a bug in the chromedriver.exe Chrome driver
for Selenium's WebDriver API. You can't use send_keys for certain types of inputs,
like for the jQuery plugin "EZPZ Hint". It works okay on simple forms.

For now I'm going to use Firefox and IE instead of Chrome to do my testing, but I'd
like to see this issue fixed. Does anyone know of a different workaround that'd allow
me to use Chrome instead of switching browsers?

Here's are inputs, had to use an image because it's generated dynamically and I couldn't
copy/paste from Chrome's inspector thing:
http://i.imgur.com/R68e6.png

I am using Chrome latest stable (14.0.835.202) and a Python script with a unittest
class and nose as the test runner.

Here's the debugging info:
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
<<

Reported by aaron.shaver@discover-e-legal.com on 2011-10-21 19:01:38

Loading

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 3, 2016

I am having the same issue, and it looks like I have issues with password text boxes.

Reported by eric.petrowiak on 2012-01-24 18:03:21

Loading

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 3, 2016

This issue no longer affects me, because our team decided to stop using EZPZ jQuery
plugin and start using the HTML placeholder attribute. I can use Chrome in my automation
suite now!

http://www.w3schools.com/html5/att_input_placeholder.asp

Reported by aaron.shaver@discover-e-legal.com on 2012-01-24 18:36:03

Loading

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 3, 2016

One workaround would be to click the element and then use the advanced interactions
API to send keys without an element.

I'll look and see if there's a better way to focus the element we want to click. Thanks
for the reproducible case.

Reported by kkania@google.com on 2012-01-27 22:24:55

  • Status changed: Accepted

Loading

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 3, 2016

I am also facing the same issue for input fields which have the search as you type feature
associated with it.

@kka : Thanks for the work around it works for me.


Reported by Talwindersingh on 2012-03-15 07:04:35

Loading

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 3, 2016

Reported by kkania@google.com on 2012-03-15 17:20:16

Loading

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 3, 2016

Moved to: Issue chromedriver:35

Reported by kkania@google.com on 2012-03-15 17:20:16

  • Status changed: Moved

Loading

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 3, 2016

Reported by luke.semerau on 2015-09-17 18:13:31

  • Labels added: Restrict-AddIssueComment-Commit

Loading

@lukeis lukeis closed this Mar 3, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant