FuckTheWorld / chromedriver

Automatically exported from code.google.com/p/chromedriver
0 stars 0 forks source link

Failed to send keys because cannot focus element in Chrome #35

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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)

Original issue reported on code.google.com by alladi....@gmail.com on 24 Aug 2011 at 4:20

GoogleCodeExporter commented 9 years ago
Still persist in chromedriver-16

Original comment by barancev on 13 Oct 2011 at 8:29

GoogleCodeExporter commented 9 years ago
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:131
9
220710066/value {"sessionId": "c85bcae35e0f07e805ea80c47ed9b75d", "id": 
":wdc:1319220710066", "value
": ["send keys stuff here, redacted"]}\n--------------------- >> end captured 
logging <<

Original comment by aaron.sh...@discover-e-legal.com on 21 Oct 2011 at 7:01

GoogleCodeExporter commented 9 years ago
I am having the same issue, and it looks like I have issues with password text 
boxes.

Original comment by eric.pet...@gmail.com on 24 Jan 2012 at 6:03

GoogleCodeExporter commented 9 years ago
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

Original comment by aaron.sh...@discover-e-legal.com on 24 Jan 2012 at 6:36

GoogleCodeExporter commented 9 years ago
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.

Original comment by kka...@google.com on 27 Jan 2012 at 10:24

GoogleCodeExporter commented 9 years ago
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.

Original comment by Talwinde...@gmail.com on 15 Mar 2012 at 7:04

GoogleCodeExporter commented 9 years ago

Original comment by kka...@google.com on 15 Mar 2012 at 5:20

GoogleCodeExporter commented 9 years ago

Original comment by kkania@chromium.org on 15 Mar 2012 at 5:22

GoogleCodeExporter commented 9 years ago
Is there any update on this issue on Chrome?

I'm just trying to navigate on a menu on my site, but I keep getting the 
message:

Selenium::WebDriver::Error::UnknownError Exception: focusElement execution 
failed;
 Failed to send keys because cannot focus element

I'm using Ruby/Capybara/Webdriver

Original comment by javar...@gmail.com on 10 Sep 2012 at 9:46

GoogleCodeExporter commented 9 years ago
I stopped having the "focusElement execution failed" problem since the 
January/2013 update.

Original comment by thiago.p...@evolucard.com.br on 6 Mar 2013 at 5:38

GoogleCodeExporter commented 9 years ago

Original comment by kkania@chromium.org on 13 Mar 2013 at 11:55

GoogleCodeExporter commented 9 years ago

Original comment by kkania@chromium.org on 14 Mar 2013 at 9:20

GoogleCodeExporter commented 9 years ago

Original comment by kkania@chromium.org on 14 Mar 2013 at 9:21

GoogleCodeExporter commented 9 years ago
This should be fixed with ChromeDriver 26. Closing.

Original comment by kkania@chromium.org on 14 Mar 2013 at 9:42

GoogleCodeExporter commented 9 years ago
I'm having the "focusElement execution failed" with the chromedriver.exe from 
January 2013 , when sending keys to a paragraf <p>   which is inside an 
<iframe>   ..  does anyone know about this issue ?

Original comment by ionelstudio@gmail.com on 27 Mar 2013 at 2:14

GoogleCodeExporter commented 9 years ago
Thanks for bringing this up.

ChromeDriver does not support typing into most <p> elements, since most users 
can't focus and type into <p> elements. If in your case the user is able to 
type into the <p>, but ChromeDriver is not, can you file a new bug with a 
simple HTML page that reproduces your problem?

Original comment by kkania@chromium.org on 27 Mar 2013 at 4:28

GoogleCodeExporter commented 9 years ago
I have created a new Issue regarding this : find it here at :  
https://code.google.com/p/chromedriver/issues/detail?id=290

Original comment by ionelstudio@gmail.com on 28 Mar 2013 at 9:49

GoogleCodeExporter commented 9 years ago
My case was a bit different but the exception was exactly the same.

It worked for me 
:http://stackoverflow.com/questions/21123539/element-after-jquery-show-and-webdr
iverexception-unknown-error-cannot-focus-el/21123540#21123540

Original comment by edu.fabr...@gmail.com on 14 Jan 2014 at 8:52

GoogleCodeExporter commented 9 years ago
I am having the same problem, unable to sendkeys across all browsers. its 
working fine in IE and firefox with xpath but its not working in chrome. Need 
help..!

Original comment by satya.ju...@gmail.com on 21 Jan 2014 at 6:40

GoogleCodeExporter commented 9 years ago
I had the same problem. I could solve by using first click(element) and then 
using send_keys(element) instead of send_keys_to_element.

Original comment by mehrdadb...@gmail.com on 6 May 2014 at 3:15

GoogleCodeExporter commented 9 years ago
Just got this using Chrome Driver 2.10

Chrome Mac OS.

Original comment by jason.sm...@1stdibs.com on 16 Jun 2014 at 6:05

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Having this problem with Chrome Version 36.0.1985.125 m on Win 8.1 using Python 
Selenium

selenium.common.exceptions.WebDriverException: Message: 'unknown error: cannot 
focus element\n  (Session info: chrome=36.0.1985.125)\n  (Driver info: 
chromedriver=2.10.267521,platform=Windows NT 6.3 x86_64)'

Original comment by rsardi...@gmail.com on 23 Jul 2014 at 8:57

GoogleCodeExporter commented 9 years ago
I am also experiencing this problem on windows 7.
unknown error: cannot focus element
  (Session info: chrome=36.0.1985.125)
  (Driver info: chromedriver=2.10.267521,platform=Windows NT 6.1 SP1 x86_64)

Original comment by norta...@gmail.com on 5 Aug 2014 at 12:20

GoogleCodeExporter commented 9 years ago
I am facing the same issue. Unable to enter text into the text field.

My operations are as follows :
1. Clicking on the text field(focus is present, i can see the cursor on the 
field).
2. While entering text using send keys(when the driver executes the step) the 
focus is gone.

Question : Is there any java script needed to overcome this error. If there is 
any, please give me the code in java.

Need help, I am blocked.

Below is the trace of the error : 
org.openqa.selenium.WebDriverException: unknown error: cannot focus element
  (Session info: chrome=36.0.1985.143)
  (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 61 milliseconds

Selenium version: selenium-java-2.42.2

Original comment by 621sivap...@gmail.com on 16 Aug 2014 at 5:21

Attachments:

GoogleCodeExporter commented 9 years ago
It worked for me with the below code snippet. Thanks

Actions actions = new Actions(driver);
actions.moveToElement(website);
actions.click();
actions.sendKeys("Some Name");
actions.build().perform();

http://stackoverflow.com/questions/21123539/element-after-jquery-show-and-webdri
verexception-unknown-error-cannot-focus-el/25342211#25342211

Original comment by 621sivap...@gmail.com on 16 Aug 2014 at 5:37

GoogleCodeExporter commented 9 years ago
Also, if you're using protractor

actions = protractor.getInstance().actions()
actions.mouseMove(element)
actions.click()
actions.sendKeys("Some text")
actions.perform()

Original comment by jeremy.s...@brightscope.com on 23 Oct 2014 at 9:41

GoogleCodeExporter commented 9 years ago
I have the following html:
<form data-ng-submit="submit()" data-ng-show="getCurrentTab()===1" 
class="navbar-form navbar-left" role="search" 
data-ng-controller="RouteTabController">
    <div class="form-group">
        FROM
        <div ba-auto-complete field="from" class="autoCompleteDirective" id="fromRoute"/>
        <button type="submit" class="btn btn-default">Submit</button>
       </div>
</form>

The following code works for ie and chrome but not firefox
        var actions = browser.actions();
        actions.mouseMove(element(by.id('fromRoute')));
        actions.click();
        actions.sendKeys("LHR");

In firefox the code does not submit data in to the from field. Any ideas?

Original comment by juliadan...@googlemail.com on 2 Dec 2014 at 11:00

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 21 Feb 2015 at 12:26

GoogleCodeExporter commented 9 years ago
am also facing the same problem , cant input to password placeholder using 
sendkeys("password")

is there any solution for this?

Original comment by balajee2...@gmail.com on 19 Mar 2015 at 12:17

GoogleCodeExporter commented 9 years ago
This also just happened for us in an autocomplete field. It seems that it only 
affects elements where you have an EventListener on focus.

Chrome: 42.0.2311.152 (64-bit)
ChromeDriver: 2.15.322448

Original comment by Sargoda...@gmail.com on 18 May 2015 at 8:57