Search fields: is there a special perform_action command for pressing the search button on the Android keyboard

477 views
Skip to first unread message

Noffica

unread,
Jul 22, 2014, 8:47:18 PM7/22/14
to calabash...@googlegroups.com
The command perform_action('send_key_enter') sends the enter key but for our search field, the enter key is replaced by the search key in the Android keyboard.

Is there a special perform_action command to send the input of the search key?

mcha...@gmail.com

unread,
Jul 23, 2014, 10:25:27 AM7/23/14
to calabash...@googlegroups.com
 I frequently refer back to this post since it's helped me so many times in the past: http://krazyrobot.com/2014/02/calabash-android-enter-text-from-keyboard-using-adb/
 
 You could try using the key code ("KEYCODE_SEARCH" - http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_SEARCH), however since I believe only keyboard_send_text(String text) has been implemented, you could try using the "keyboard_enter_event" which is below. Should should call it by .........  keyboard_enter_event("KEYCODE_SEARCH").

*INPUT TEXT: already implemented* (no need to use perform_action(send_text("text))

 def keyboard_enter_text(text)
    # escape all non-alphanumeric characters with \
    processed_text = text.gsub(/([^\w\s])/) { |c| '\\' + c }
 
    # replace spaces with %s
    processed_text = processed_text.gsub(' ', '%s')
 
    input_command = "#{default_device.adb_command} shell input text #{processed_text}"
    raise "Could not send keyboard text: #{text}" unless system(input_command)
  end

*INPUT KEY_EVENT: Not implemented (I believe)*
 def keyboard_enter_event(event)
    input_command = "#{default_device.adb_command} shell input keyevent #{processed_text}"
    raise "Could not send keyboard text: #{text}" unless system(input_command)
  end

Noffica

unread,
Jul 23, 2014, 12:54:39 PM7/23/14
to calabash...@googlegroups.com
Firstly, thanks for your help.

Unfortunately, I have been unable to work with it. I bring focus to the search field then execute 
system("adb shell input key event KEYCODE_SEARCH")
 but that has no effect whatsoever.

system("adb shell input keyevent KEYCODE_SPACE")
 and 
system("adb shell input keyevent KEYCODE_A")
 will insert a space and the letter "a" respectively but
system("adb shell input keyevent KEYCODE_SEARCH")
 
does not work.

Noffica

unread,
Jul 23, 2014, 12:55:55 PM7/23/14
to calabash...@googlegroups.com
That was all done in
calabash-android console

Bharath Bachina

unread,
Apr 12, 2015, 11:22:33 PM4/12/15
to calabash...@googlegroups.com
Hi Noffica,

   I am also facing same problem, if you found any solution please post it.

Nauman Mithani

unread,
Apr 13, 2015, 12:26:18 PM4/13/15
to calabash...@googlegroups.com
I found a solution but I haven't used it. Check the latest documentation on the 'press user action button' commands. I believe it has been resolved.



--
You received this message because you are subscribed to a topic in the Google Groups "calabash-android" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/calabash-android/LRF1pRVSFvI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to calabash-andro...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages