SeleniumHQ / selenium-google-code-issue-archive

Archive, please see main selenium repo
https://github.com/seleniumhq/selenium
345 stars 195 forks source link

android: sendKeysToElement mixes up strings longer than 9 characters #1319

Closed lukeis closed 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 1319

It seems like after typing 9 characters, the focus reverts to the first character before
typing the 10th, so that further characters are inserted in the wrong place.

What steps will reproduce the problem?

Using ruby remote webdriver in a jruby IRB session:

> driver.get("http://google.com/")
 => nil 
> el = driver[:name => 'q']
 => #<Selenium::WebDriver::Element:0x62 id="0" tag_name="input">
> el.send_keys('123456789')    
 => ["123456789"]

# (input now contains the correct "123456789")
> el.clear

# input is empty. now try a string longer than 9 chars:

> el.send_keys('123456789abcd')
 => ["123456789abcd"]

# input now contains the INCORRECT "1abcd23456789"

> el.value
 => "1abcd23456789"

What version of the product are you using? On what operating system?

I can reproduce this with both beta 1 and 2 apks, running the android emulator on linux
with an android 2.2 image.

Please provide any additional information below.

I've added debug output in the selenium-webdriver gem installed locally, to the webdriver/remote/bridge.rb#execute
method. The error is definitely on android's side, as when I run send_keys, it prints:

EXECUTING: [:sendKeysToElement, {:id=>"0"}, {:value=>["1", "2", "3", "4", "5", "6",
"7", "8", "9", "a", "b", "c", "d"]}]

Typing in the same string to the emulator manually gives the correct result.

Reported by gfxmonk on 2011-02-21 00:18:06

lukeis commented 8 years ago
investigating with longer strings:

> el.send_keys('123456789a1a2a3a4a5a6a7a8a9b1b2b3b4b5b6b7b8b9')
EXECUTING: [:sendKeysToElement, {:id=>"0"}, {:value=>["1", "2", "3", "4", "5", "6",
"7", "8", "9", "a", "1", "a", "2", "a", "3", "a", "4", "a", "5", "a", "6", "a", "7",
"a", "8", "a", "9", "b", "1", "b", "2", "b", "3", "b", "4", "b", "5", "b", "6", "b",
"7", "b", "8", "b", "9"]}]
 => ["123456789a1a2a3a4a5a6a7a8a9b1b2b3b4b5b6b7b8b9"] 

> el.value                                                     
EXECUTING: [:getElementValue, {:id=>"0"}]
 => "1a1a2a3a4a52a6a7a8a9b13b2b3b4b5b64b7b8b956789"

The pattern seems to be:
characters 10 through 19 (inclusive) are inserted after character 1 of the original
string
characters 20 through 29 are inserted after character 2 of the original string
characters 30 through 39 are inserted after character 3 of the original string
..etc

It looks a lot like something somewhere is using string order instead of numerical
order for an index.

Reported by gfxmonk on 2011-02-21 00:43:12

lukeis commented 8 years ago
Cc'ing Dounia for further investigation. 

PS. You can get similar debug output without hacking the gem by setting $DEBUG = true
(or running ruby with -d).

Reported by jari.bakken on 2011-02-22 01:55:56

lukeis commented 8 years ago

Reported by berrada@google.com on 2011-06-20 22:06:27

lukeis commented 8 years ago

Reported by berrada@google.com on 2011-06-20 22:06:40

lukeis commented 8 years ago

Reported by berrada@google.com on 2012-01-27 16:55:36

lukeis commented 8 years ago
The AndroidDriver is no longer supported.

See
revision ef9d5787e5e136ecb4a31b0cf53a1fd17e252cf3
revision 3495003a29322fecbdf9e5ddf6cd7c6488539992

For Android automation, take a look at Selendroid or Appium:
https://github.com/appium/appium
http://selendroid.io/

Reported by jmleyba on 2013-12-19 06:39:14

lukeis commented 8 years ago

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