Search keyboard Appium Java not function

我怕爱的太早我们不能终老 提交于 2021-01-28 08:25:49

问题


try to find a solution for this topic and none of the answers all the websites won't help me,

Search keyboard Appium Java not function

example not helping codes:

((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.ENTER));

same with:

driver.sendKeyEvent(AndroidKeyCode.ENTER);

or:

((AndroidDriver)driver).pressKeyCode(66)

or:

((AndroidDriver)driver).pressKeyCode(84)

I'm using this appium version:

<dependency>
    <groupId>io.appium</groupId>
    <artifactId>java-client</artifactId>
    <version>6.1.0</version>
</dependency>

the option do it via coordinates not workaround for me since this tests done with a real mobiles and any mobile with a different screen size resolution

Sharing the exception and stack trace

org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters.
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'Haims-MacBook', ip: 'fe80:0:0:0:8ea:4c20:85c7:1988%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '1.8.0_112'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {appActivity: net.XXX.XXX.ui.acti..., appPackage: net.XXX.XXX.qa, databaseEnabled: false, desired: {appActivity: net.XXX.XXX.ui.acti..., appPackage: net.XXX.XXX.qa, deviceName: Galaxy A20, noReset: false, platformName: android, platformVersion: 9}, deviceManufacturer: samsung, deviceModel: SM-A205FN, deviceName: R58M50DVABW, deviceScreenSize: 720x1560, deviceUDID: R58M50DVABW, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, noReset: false, platform: LINUX, platformName: Android, platformVersion: 9, takesScreenshot: true, warnings: {}, webStorageEnabled: false}
Session ID: ad88e2fa-102c-4e19-b8fa-ac48054838ff

回答1:


capabilities.setCapability("unicodeKeyboard", "true");                                     
capabilities.setCapability("resetKeyboard", "true");

set this before trying

((AndroidDriver)driver).pressKeyCode(AndroidKeyCode.ENTER)



回答2:


You can use below code to press search button.

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

If this doesn't work try replacing search with below commands

  1. go
  2. send
  3. next
  4. done

Also, if this doesn't work try giving 1 or 2 sec delay before the execution of this command. For more information you can refer http://appium.io/docs/en/commands/mobile-command/



来源:https://stackoverflow.com/questions/57872002/search-keyboard-appium-java-not-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!