Unable to execute search – Appium Ruby 1.9.0


#1

Appium 1.9.0
Ruby 2.5.1
Android 7.0
App under test is a native Android application.

I’m not able to tap the search action key on the keyboard to execute a search.

press_keycode(66) simply removes the focus from the search field which then makes the soft keyboard show the return button in place of the search button.

press_keycode(84) doesn’t appear to do anything.

send_keys("search term" + "\n") just enters "search term " (search term with a trailing white space) in the text field but does not take any action to execute the search and dismiss the keyboard.

Tapping on the search button coordinates is not an acceptable option.

It appears that that field is waiting for IME_ACTION_SEARCH but after some extensive searching, I’m not able to find a way to send that event, either through Appium or someway directly through adb shell. If anyone is also familiar with Calabash, I’m trying to do what I could do in Calabash with press_user_action_button('search') – I"m just a little less familiar with Appium. From what I’ve found so far, this is broken in Appium 1.9.0 for Ruby.


#2

I’ll try to port this feature to Appium. Would you help me with PR testing?


#3

I’d be happy to! Just let me know when you’re ready.

As an additional note, it would be great if this could also include support for other action buttons such as ‘Go’ and ‘Done’


#4

for now you could try if https://github.com/appium/java-client/issues/916 works for you


#5

Is there a way of utilizing this Appium Java solution in our current Appium Ruby environment that I’m not aware of?


#6

Try https://github.com/appium/ruby_lib_core/blob/ba9dd3c06e128421a256a06638483f584df6b59f/test/functional/android/driver_test.rb#L47

The beta version of appium server should be installed, otherwise this code won’t work


#7

I updated appium to the beta version.
$ npm install -g [email protected]

$ appium -v
1.9.2-beta.1

After cloning ruby_lib_core, I updated the android capabilities in ruby_lib_core/test/test_helper.rb to include the udid of my connected physical device (and updated the other caps to the appropriate values for my device). I then ran…

$ appium --relaxed-security
[Appium] Welcome to Appium v1.9.2-beta.1
[Appium] Non-default server args:
[Appium] relaxedSecurityEnabled: true
[Appium] Appium REST http interface listener started on 0.0.0.0:4723

From the ruby_lib_core directory, I ran…

$ rake test:func:android TEST=test/functional/android/driver_test.rb
Started with run options --seed 4819

I got the following error when the test_mobile_perform_action test was executed:

ERROR["test_mobile_perform_action", #<Minitest::Reporters::Suite:0x00007faf4f9e5dd0 @name="AppiumLibCoreTest::DriverTest">, 79.02376800001366]
 test_mobile_perform_action#AppiumLibCoreTest::DriverTest (79.02s)
Selenium::WebDriver::Error::UnknownCommandError:         Selenium::WebDriver::Error::UnknownCommandError: Unknown mobile command "performEditorAction". Only shell,scrollBackTo,viewportScreenshot,deepLink,startLogsBroadcast,stopLogsBroadcast,acceptAlert,dismissAlert,batteryInfo,deviceInfo commands are supported.
            UnknownCommandError: Unknown mobile command "performEditorAction". Only shell,scrollBackTo,viewportScreenshot,deepLink,startLogsBroadcast,stopLogsBroadcast,acceptAlert,dismissAlert,batteryInfo,deviceInfo commands are supported.
                at AndroidUiautomator2Driver.callee$0$0$ (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/commands/general.js:85:11)
                at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
                at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
                at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
                at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
                at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
                at new Promise (<anonymous>)
                at new F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
                at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
                at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
                at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
                at AndroidUiautomator2Driver.callee$0$0 [as executeMobile] (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/build/lib/commands/general.js:191:30)
                at AndroidUiautomator2Driver.callee$0$0$ (/usr/local/lib/node_modules/appium/node_modules/appium-android-driver/lib/commands/execute.js:9:23)
                at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
                at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
                at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
                at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
                at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
                at new Promise (<anonymous>)
                at new F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
                at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
                at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
                at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
                at AndroidUiautomator2Driver.callee$0$0 [as execute] (/usr/local/lib/node_modules/appium/node_modules/appium-android-driver/build/lib/commands/execute.js:20:30)
                at /usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:296:26
                at tryCatcher (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/util.js:26:23)
                at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/promise.js:510:31)
                at Promise._settlePromiseAt (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/promise.js:584:18)
                at Promise._settlePromiseAtPostResolution (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/promise.js:248:10)
                at Async._drainQueue (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/async.js:128:12)
                at Async._drainQueues (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/async.js:133:10)
                at Immediate.Async.drainQueues (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/node_modules/bluebird/js/main/async.js:15:14)
                at runCallback (timers.js:694:18)
                at tryOnImmediate (timers.js:665:5)
                at processImmediate (timers.js:647:5)
            /Users/(user_account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok'
            /Users/(user_account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/response.rb:32:in `initialize'
            /Users/(user_account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/http/common.rb:84:in `new'
            /Users/(user_account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/http/common.rb:84:in `create_response'
            /Users/(user_account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/http/default.rb:104:in `request'
            /Users/(user_account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/http/common.rb:62:in `call'
            /Users/(user_account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/bridge.rb:164:in `execute'
            /Users/(user_account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/w3c/bridge.rb:552:in `execute'
            /Users/(user_account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/w3c/bridge.rb:292:in `execute_script'
            /Users/(user_account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/common/driver.rb:211:in `execute_script'
            /Users/(user_account)/gitrepo/ruby_lib_core/test/functional/android/driver_test.rb:58:in `test_mobile_perform_action'

Appium logs are attached.

appium_logs.txt (174.3 KB)


#8

It looks like the change is still not published for UIA2. Please wait a while until it is there


#9

My apologies if this is an elementary question, but how will I be able to tell? Will this show up as a new appium beta version (perhaps 1.9.2-beta.2 is a similar place as 1.9.2-beta.1 here: https://www.npmjs.com/package/appium/v/1.9.2-beta.1) that I’ll have to install via npm or am I missing something? Newer to Appium so I do appreciate your help.


#10

the change will be available in beta as soon as https://github.com/appium/appium-uiautomator2-driver project gets the next version tag. Then it would be enough to simply reinstall the beta:

npm uninstall -g appium
npm i -g [email protected]

#11

The module has been tagged. The feature is available there since 1.20.0


#12

#13

I ran:

npm uninstall -g appium
nom i -g [email protected]

However, I’m still getting an error running the functional testing in ruby_lib_core:

ERROR["test_mobile_perform_action", #<Minitest::Reporters::Suite:0x00007fde9398d310 @name="AppiumLibCoreTest::DriverTest">, 46.956337000010535]
 test_mobile_perform_action#AppiumLibCoreTest::DriverTest (46.96s)
Selenium::WebDriver::Error::UnknownError:         Selenium::WebDriver::Error::UnknownError: An unknown server-side error occurred while processing the command. Original error: this.adb.performEditorAction is not a function
            UnknownError: An unknown server-side error occurred while processing the command. Original error: this.adb.performEditorAction is not a function
                at getResponseForW3CError (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:826:9)
                at asyncHandler$ (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:404:37)
                at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
                at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
                at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
                at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok'
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/response.rb:32:in `initialize'
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/http/common.rb:84:in `new'
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/http/common.rb:84:in `create_response'
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/http/default.rb:104:in `request'
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/http/common.rb:62:in `call'
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/bridge.rb:164:in `execute'
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/w3c/bridge.rb:552:in `execute'
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/w3c/bridge.rb:292:in `execute_script'
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/common/driver.rb:211:in `execute_script'
            /Users/(user account)/gitrepo/ruby_lib_core/test/functional/android/driver_test.rb:58:in `test_mobile_perform_action'

Appium logs attached as appium_logs_0927.txt (172.9 KB)

I also tried just executing the command in app via Appium Ruby Console. After getting to a search field and entering some characters, I switched the keyboard to Appium Android Input Manager (something I assume Appium will handle on it’s own?), retrieved the app from the background and executed:

execute_script("mobile: performEditorAction", {"action" => "Search"})

This led to the following error:

Selenium::WebDriver::Error::UnknownError: An unknown server-side error occurred while processing the command. Original error: this.adb.performEditorAction is not a function
from UnknownError: An unknown server-side error occurred while processing the command. Original error: this.adb.performEditorAction is not a function

Appium logs for that arc session are attached as appium_arc_logs.txt (6.7 KB)


#14

Can you make sure the actual version of appium-adb component is at 6.20.0+ ?


#15

Would this be installed with $ npm i -g [email protected] ?

Without being sure… here’s what I did:
I saw that on the https://github.com/appium/appium-adb page, the npm version is still 6.19.0. So I cloned the appium-adb repo, switched to that directory, and ran…

npm i -g .

And saw + [email protected] near the end of that output.

Switching back to the ruby_lib_core directory, starting appium --relaxed-security and running the driver_test.rb functional tests again resulted in the same error:

ERROR["test_mobile_perform_action", #<Minitest::Reporters::Suite:0x00007f801a11ebe8 @name="AppiumLibCoreTest::DriverTest">, 73.97040399996331]
 test_mobile_perform_action#AppiumLibCoreTest::DriverTest (73.97s)
Selenium::WebDriver::Error::UnknownError:         Selenium::WebDriver::Error::UnknownError: An unknown server-side error occurred while processing the command. Original error: this.adb.performEditorAction is not a function
            UnknownError: An unknown server-side error occurred while processing the command. Original error: this.adb.performEditorAction is not a function
                at getResponseForW3CError (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:826:9)
                at asyncHandler$ (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:404:37)
                at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
                at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
                at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
                at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok'
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/response.rb:32:in `initialize'
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/http/common.rb:84:in `new'
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/http/common.rb:84:in `create_response'
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/http/default.rb:104:in `request'
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/http/common.rb:62:in `call'
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/bridge.rb:164:in `execute'
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/w3c/bridge.rb:552:in `execute'
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/remote/w3c/bridge.rb:292:in `execute_script'
            /Users/(user account)/.rvm/gems/ruby-2.5.1/gems/selenium-webdriver-3.14.0/lib/selenium/webdriver/common/driver.rb:211:in `execute_script'
            /Users/(user account)/gitrepo/ruby_lib_core/test/functional/android/driver_test.rb:58:in `test_mobile_perform_action'

When trying a different route in my app using appium ruby console, I saw the same error and appium log output as yesterday.

I appreciate the understanding that much of this is new to me so I’m trying to give you as much info as I can. Is there something I’m missing here?


#16

Sorry for your troubles. To me it looks like there was a problem by publishing appium-adb module to npm. We’ll try to address the problem


#17

The problem with package publishing seems to be fixed. Please try again


To press search on keyboard in appium
#18

Thanks for this a lot, but as I understand this can be only implemented with Java, any ideas when and how it will be available with python-client?


#19

@mykola-mokhnach Sorry for the delay. Looks to be working!

Functional test results:

$ rake test:func:android TEST=test/functional/android/driver_test.rb
Started with run options --seed 59268

  6/6: [======================================================================] 100% Time: 00:02:32, Time: 00:02:32

Finished in 152.41870s
6 tests, 10 assertions, 0 failures, 0 errors, 0 skips

I was also able to confirm that the command works in our app via an Appium Ruby Console.

execute_script("mobile: performEditorAction", { "action" => "next" })

This is great! Thanks for all your hard work on this!