How to press ENTER keyboard when search data on mobile apps

Hi @Chris_Trevarthen Thank You.

Have tried the above solution but actually the issue is post entering the text I am using Mobile.hidekeyboard() but its not working as an enter. So I think here have to use some keyboard enter event just to get the search result.

I have used the driver = MobileDriverFactory.getDriver()
driver.pressKey(new KeyEvent(AndroidKey.ENTER)) but looks like the PressKey is deprecated.

Hi @QA21,

You’re right, I don’t think the Mobile.hideKeyboard() function is guaranteed to send a return/enter key. I think that pressKey is still ok, but pressKeyCode is deprecated per the Appium docs:

https://appium.github.io/java-client/index.html?io/appium/java_client/android/nativekey/PressesKey.html

If pressKey is working for you, I would say to keep using it. If it’s not, let’s troubleshoot further.

– Chris

Hi @Chris_Trevarthen tried so many ways but still struggling with the above.
Could you pleas help me out?

Hi @QA21,

If none of the above options work for you, you can try using the tapAtPosition function, tapping at the coordinates where the enter button will be. You should be able to calculate this based on your screen size:

https://docs.katalon.com/katalon-studio/docs/mobile-tap-at-position.html

Hope this helps,

Chris

1 Like

It worked for me, thanks @Goran

1 Like

Hello Everyone, If you still didn’t get any solution regarding this, then try this. It’s works for me.

First Import

    import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory as MobileDriverFactory
    import io.appium.java_client.android.AndroidDriver as AndroidDriver
    import org.openqa.selenium.Keys as Keys
    import com.kms.katalon.core.logging.KeywordLogger
    import com.google.common.collect.ImmutableMap as ImmutableMap;

Then called AndroidDriver

AndroidDriver<?> driver = MobileDriverFactory.getDriver()

Now select that Text field by spying/recording/from captured object class name and send your desired text:

driver.findElement(By.className('android.widget.EditText')).click()
Mobile.delay(3)
driver.getKeyboard().sendKeys("milk")

Now Click on search by writing this command

driver.executeScript("mobile: performEditorAction", ImmutableMap.of("action", "search"));

1 Like