question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SendKeys is clearing the text from editText1 while trying to insert into editText2 (individual pin textboxes)

See original GitHub issue

The problem

I have an app that asks the user to enter a pin code. The pin code consists of 4 different editText elements (editText1, editText2, etc…).

I am calling the .SendKeys(“1”) method for each editText item (IWebElement).

driver.FindElement(By.Id("com.myapp.androidphone:id/editText1")).SendKeys("1");
driver.FindElement(By.Id("com.myapp.androidphone:id/editText2")).SendKeys("1");

When I call the editText2.SendKeys(“2”) method, a call to the UiObject.ClearText() method is invoked and this wipes out my editText1 value. So essentially, i can never fill out all of the editText textboxes because each call for populating an editText is wiping out the previous textbox value.

Example: EditText1.SendKeys(“1”); (This populates the first pin number square). EditText2.SendKeys(“1”); (This populates the second pin number square, however it wipes out the first pin square).

image

So, is this a bug or am I using SendKeys incorrectly. Also, does anyone have any idea on how I can go about entering a value without clearing the previous field.

Environment

  • Appium version: v1.5.0:
  • Desktop: WIN 7 Pro
  • Node.js version: v4.4.0
  • Mobile platform/version under test: Android
  • Real device or emulator/simulator: Emulator Nexus 5 API 19 (4.4.2)
  • Appium CLI

Link to Appium logs

016-03-28 12:26:40:237 - info: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.myapp.androidphone:id/editText1]
2016-03-28 12:26:40:238 - info: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":{"ELEMENT":"25"},"status":0}
2016-03-28 12:26:40:239 - info: [debug] [AndroidBootstrap] Received command result from bootstrap
2016-03-28 12:26:40:240 - info: [MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"25"}
2016-03-28 12:26:40:241 - info: [HTTP] <-- POST /wd/hub/session/361c5ace-ec8e-487e-a2d7-be57f086a9c7/element 200 14 ms - 88 
2016-03-28 12:26:40:242 - info: [HTTP] --> POST /wd/hub/session/361c5ace-ec8e-487e-a2d7-be57f086a9c7/element/25/value 
2016-03-28 12:26:40:243 - info: [MJSONWP] Calling AppiumDriver.setValue() with args: [["1"],"25","361c5ace-ec8e-487e-a2d7-be57f086a9c7"]
2016-03-28 12:26:40:244 - info: [debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:setText","params":{"elementId":"25","text":"1","replace":false,"unicodeKeyboard":true}}
2016-03-28 12:26:40:247 - info: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:setText","params":{"elementId":"25","text":"1","replace":false,"unicodeKeyboard":true}}
2016-03-28 12:26:40:251 - info: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
2016-03-28 12:26:40:251 - info: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: setText
2016-03-28 12:26:40:251 - info: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using element passed in.
2016-03-28 12:26:40:253 - info: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Attempting to clear using UiObject.clearText().
2016-03-28 12:26:43:290 - info: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Sending plain text to element: 1
2016-03-28 12:26:46:526 - info: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":true,"status":0}
2016-03-28 12:26:46:526 - info: [debug] [AndroidBootstrap] Received command result from bootstrap
2016-03-28 12:26:46:527 - info: [MJSONWP] Responding to client with driver.setValue() result: true

2016-03-28 12:27:01:732 - info: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.myapp.androidphone:id/editText2]
2016-03-28 12:27:01:748 - info: [debug] [AndroidBootstrap] Received command result from bootstrap
2016-03-28 12:27:01:749 - info: [MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"26"}
2016-03-28 12:27:01:751 - info: [HTTP] <-- POST /wd/hub/session/361c5ace-ec8e-487e-a2d7-be57f086a9c7/element 200 43 ms - 88 
2016-03-28 12:27:01:752 - info: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":{"ELEMENT":"26"},"status":0}
2016-03-28 12:27:01:753 - info: [HTTP] --> POST /wd/hub/session/361c5ace-ec8e-487e-a2d7-be57f086a9c7/element/26/value 
2016-03-28 12:27:01:755 - info: [MJSONWP] Calling AppiumDriver.setValue() with args: [["1"],"26","361c5ace-ec8e-487e-a2d7-be57f086a9c7"]
2016-03-28 12:27:01:759 - info: [debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:setText","params":{"elementId":"26","text":"1","replace":false,"unicodeKeyboard":true}}
2016-03-28 12:27:01:770 - info: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:setText","params":{"elementId":"26","text":"1","replace":false,"unicodeKeyboard":true}}
2016-03-28 12:27:01:770 - info: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
2016-03-28 12:27:01:770 - info: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: setText
2016-03-28 12:27:01:771 - info: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using element passed in.
2016-03-28 12:27:01:772 - info: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Attempting to clear using UiObject.clearText().
2016-03-28 12:27:05:310 - info: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Sending plain text to element: 1
2016-03-28 12:27:08:203 - info: [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":true,"status":0}
2016-03-28 12:27:08:203 - info: [debug] [AndroidBootstrap] Received command result from bootstrap
2016-03-28 12:27:08:204 - info: [MJSONWP] Responding to client with driver.setValue() result: true

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
imurchiecommented, Mar 28, 2016

This sounds like a bug. I’m exploring locally. Thanks for reporting!

0reactions
lock[bot]commented, Apr 27, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

6 text boxes, used click to find them, but sendKeys() is sending ...
EditText "). b) Send text to each textbox for element in elements: element.sendKeys("Hello world!"); If there more textboxes in same view but need...
Read more >
Solved: Send Keys is populating the text box as {tab} inst...
I have a Microsoft Navigate form I'm working on populating and some of the text fields on a page are failing to be...
Read more >
Unable to enter space in the Textbox using sendkeys() method
Hi all,. I am trying to enter space in the text box using send keys but it is not working instead when command...
Read more >
Selenium - sendKeys() not inserting value into textbox
First once clear the input text fields and send the input values. ... in phone text field objSSN.clear(); //To clear the phone ssn...
Read more >
Unable to clear complete text from the User name field
Is there any command to clear all the entered text in that field? ... there an explanation as to why 2 clears are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found