I am using Android emulator to test an application.
I am able to enter text in a text a text field, and trying to enter click enter by following code:
element.sendKeys("Some text");
element.sendKeys(Keys.ENTER); also tried with Keys.RETURN // both of these deleting the text which i entered in the text field rather than clicking enter.
So i tried to simulate this by using Actions class like below:
Actions action=new Actions(driver)
action.sendKeys("Some text").sendKeys(Keys.ENTER).build().perform();//Here i am getting an exception saying it is not yet implemented.
So can anyone help me to provide a solution to the problem.
Not sure if you have named the web element/mobile element as driver. There isnât any sendKeys() method with driver.
And for sending the enter key you have to use key event i.e. driver.sendKeyEvent(Keys.ENTER);
Hii,
You can try this code:
driver.pressKeyCode(AndroidKeyCode.KEYCODE_NUMPAD_ENTER );
since âsendkeycodeâ is not available now and âenter in number padâ is working.
Any of the above tricks are not working with me. Any other option?
Below is my code to enter password and then enter key.
By password = By.id(app_package_name_with_id + âet_passwordâ);
WebElement enterPassword = driver.findElement(password);
enterPassword.sendKeys(â12345â);
Please refer the attached image to get more clear idea about my query:
After entering the one number in To: textbox I will click on the icon mark in yellow, after clicking on the yellow icon the cursor will appear on the To: textbox after the first number which was entered previously.
The Cursor is indicated in the image using the orange line.
When I try to enter another number after the cursor, it will overlap the previous number and the previous number would be erased so please help me to solve this issue
No idea, I havenât came across scenario like this. Try to do the same steps manually and see whatâs happening and based on that try to modify your code
This will allow you to execute adb shell input text âANY STRINGâ command from your script.
Find the element locator for Recipient text box.
Example :MobileElement element=driver.findElement(By.id(âcom.google.android.apps.messaging:id/recipient_text_viewâ));
Below is the Custom Method which tap on recipient(To text box) and enter multiple String(Contact Numbers) one after another
driver.executeScript(âmobile: shellâ, cmd);
mobile :shell will execute as adb shell commands with arguments. Example : adb shell input text '13444â input is the adb shell command used to perform some operation and text is the argument which decide the operation will enter data in the textfield. â13444â is the data passed to the textfield.
2.Map<String, Object> cmd = ImmutableMap
.of(âcommandâ, âinputâ, âargsâ, enterText);
Now cmd here contain two key-value. Input
is the value for key âcommandâ. In similar way args keys contains command arguments.
This allowed me to find a text field, input some text, and submit a search command (same as clicking the search icon in the keyboard). Of course, you have to replace <elementId> and <text to type> with the proper values. See http://appium.io/docs/en/commands/mobile-command/ for details on âmobile: performEditorActionâ.