Sendkeys() not release the Element in Android App using Appium - android

WebElementUserAccount=driver.findElement(By.xpath("//android.widget.EditText[#content-desc='User account']"));
UserAccount.click();
UserAccount.sendKeys("Test");
When I use this code it is not releasing the User account element it sends the text successfully but not came out of it
In the second element, I have to send the password but it will not come out from the first Element
When I use
WebElement UserName= driver.findElement(By.xpath("//android.widget.EditText[#content-desc='User account']"));
WebElement Password= driver.findElement(By.xpath("//android.widget.EditText[#content-desc='Password']"));
UserName.sendKeys("UserName");
The Android keybord open before sending the text and it starts writing in the second element

Use driver.hideKeyboard(); after entering text in your first element. Your keyboard might be hiding next element.

Whenever you do automation its better to turn off the text suggestion(predictive text) in the mobile keyboard.
Check whether the keyboard is displayed . If displayed use the following code:
driver.hideKeyboard();

Related

Unable to enter data on edittext fields of appium

I am entering data on these checkboxes. The script runs fine but data does not enters. Check the code below:
List<WebElement>pincode = driver.findElements(By.id("com.theentertainerme.entertainer:id/pin_code_round)"));
pincode.get(0).sendKeys("0");
pincode.get(1).sendKeys("0");
pincode.get(2).sendKeys("0");
pincode.get(3).sendKeys("0");
Check UI of screen
Image added is of UiAutomatorViewer
Please help me out on this.
Instead of doing like that you can enter the four digits by using android keycodes.
driver.pressKeyCode(AndroidKeyCode.KEYCODE_1);
driver.pressKeyCode(AndroidKeyCode.KEYCODE_1);
driver.pressKeyCode(AndroidKeyCode.KEYCODE_1);
driver.pressKeyCode(AndroidKeyCode.KEYCODE_1);
This will enter all 1's in the four fields.

Sending tab key event?

Is it possible to send a tab key press with calabash? I'm having difficulty selecting elements in a browser view on Android.
I've tried the following things:
enter_text("WebView css:'#Email'", "email#email.com")
enter_text("android.widget.EditText id:'#Email'", "email#email.com")
But they don't seem to be seen by calabash to select. I'm now wondering if I send certain number of tab presses, I should also end up in the field that I want. How do I send a tab key press though?
Additionally, is it possible to send text to an element that has the active focus, without specifying an id of the element?
Thanks in advance
"Is it possible to send a tab key press with calabash?"
Yes, it is.
press_user_action_button('next')
If you are using Cordova, you should change the Webview to cordovaWebView or SystemWebView.
enter_text("SystemWebView css:'#Email'", "email#email.com")
"Additionally, is it possible to send text to an element that has the active focus, without specifying an id of the element?"
Yes, it is.
keyboard_enter_text("text")

Registered user check for lowercase or uppercase

I want to know how to check the existing users for either upper or lowercase when a new user is signing up. At present for example the followig two users can be registered
tom and Tom, both of these are considered as two separate users, so if this happens I want to sound off to the user that the username already exists. Where in code exactly can I do this?
You can create a textwatcher for the edittext where user enters loginname and when focus changes from the edittext get the string in there using getText and pass this to an api which will check the username with db to check for similarity and will return a status false if similar user exits and you can show a red underline or red hidden badge to side of the edittext on the basis of this result to notify the user that such a username already exists.

Tap on search Button in android device with appium is not working

I am trying to type in a search box within my app and tap/click on search button (magnifying glass) on keyboard. But I am unable to click/tap on it. I have tried below things: driver.sendKeyEvent(84); Appium says it successfully sent in the command but 'search' does not get tapped. Cursor remains in text box and results do not filter.
HashMap swipeObject = new HashMap();swipeObject.put("keycode", 84);((JavascriptExecutor ) driver).executeScript("mobile: keyevent", swipeObject);
Appium says: not yet implemented
find element by id or path and then use click.
driver.findElement(By.id("SearchButton-Id")).click();
driver.findElement(By.xpath("//xpath given by UIAutomator")).click();
If you can post the screenshot of UIAutomator, I can tell you xpath.
Use this for search button on keyboard:
driver.sendKeyEvent(AndroidKeyCode.ENTER);
For this, you need "import io.appium.java_client.android.AndroidKeyCode;"
Try below java code-
driver.executeScript("mobile: performEditorAction", ImmutableMap.of("action", "search"));
action: The name or an integer code of the editor action to be executed. The following action names are supported: normal, unspecified, none, go, search, send, next, done, previous

Android application

Whenever i login to application i need to enter the password.But next time when i enter the password it shows me complete password over the soft keyboard of android.I need to clear this
data from android memory.
If you don't want the password hint to be shown try adding the following to your EditText attributes
android:inputType="textFilter|textMultiLine|textNoSuggestions"

Categories

Resources