Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

sendKeysToElement function works key-by-key and using sendKeys with large amount of text data is very slowly and execution timeout elapsed #2876

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

Comments

@lukeis
Copy link
Member

lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 2876

What steps will reproduce the problem?
- Selenium.type() or Selenium.typeKeys() or WebElement.sendKeys()
All these are using typing key-by-key. And when the amount of text data is large the
typing takes minutes and the execution timeout elapsed. I can increase the execution
Timeout, but the main problem is test execution time.
I think that it's stupid to set text value of an Input (or text area) element typing
key-by-key.
I can also fix this using JS executors and setting the element value directly, but
in this way I can't use the XPath element locators.

Selenium version: 2.11.0 (also with 2.12.0)
OS: XP, also in Gentoo
Browser: FF
Browser version: 7, 8

Reported by stanimir.komitov on 2011-11-18 12:51:32

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Selenium.type() sets the value of a text field directly.

WebDriver.sendKeys() sends key by key to emulate real user interaction. If you want
to put a large amount of text to a field you may paste it from the clipboard, like
a user would do it.

You should put your data on the clipboard first, and then Ctrl-v it to a text area
or an input.

How to put data on the clipboard?
.Net: http://www.c-sharpcorner.com/UploadFile/mahesh/WorkingwithSystemClipboard12032005043903AM/WorkingwithSystemClipboard.aspx
Java: http://www.exampledepot.com/egs/java.awt.datatransfer/ToClip.html

How to insert the data from the clipboard to an element:
element.sendKeys(Keys.CONTROL + "v");

Reported by barancev on 2011-11-18 13:20:29

  • Status changed: WorkingAsIntended
  • Labels added: Component-WebDriver

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

The workaround with Ctrl + V works fine.
About the Selenium.type().
It is calling WebDriver.sendKeys(), which means that it's the same as WebDriver.sendKeys()
and sends key by key to emulate real user interaction. You can check it.

Reported by stanimir.komitov on 2011-11-18 13:32:53

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Selenium.type() calls WebDriver.sendKeys() if you use WebDriverBackedSelenium (aka "emulation
mode"). If you use DefaulSelenium, 'type' assigns value directly.

Reported by barancev on 2011-11-20 20:36:14

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

You are right, but I thing the last year the main development of Selenium team is related
to WebDriver, and the Documentation says that the we should use WebDriverBackedSelenium.
You also add the right issue label -> Labels: Component-WebDriver. 
Another 'bug' is when using:
 element.sendKeys(Keys.CONTROL + "v")
( even if using Keys.chord( Keys.CONTROL, "v" ) ) the Ctrl key is not released correctly
and if you try to click a link after that, the link is opened in a new tab.
This is a simple test - one text field and one link.

Reported by stanimir.komitov on 2011-11-22 12:29:02

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

This last note (about sticky Ctrl) would be good to report as a separate issue.

Reported by barancev on 2011-11-22 12:32:54

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

This last note (about sticky Ctrl) would be good to report as a separate issue.

Reported by barancev on 2011-11-22 12:32:55

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Added - Issue 2908 (http://code.google.com/p/selenium/issues/detail?id=2908)

Reported by stanimir.komitov on 2011-11-22 12:55:01

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

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

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed 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
Development

No branches or pull requests

1 participant