1

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?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Noffica
  • 469
  • 8
  • 23

3 Answers3

1

What could be happening is your scripts aren't able to accurately locate ADB in order to send the command to the device. Try using the following, which uses default_device.adb_command - this should use the full path to ADB and also use the proper device id:

system("#{default_device.adb_command} shell input keyevent KEYCODE_ENTER")

Also, I can't take credit for this, so go ahead and take a look at this great post which helped me immensely when dealing with entering text:

lux
  • 8,315
  • 7
  • 36
  • 49
  • I tried it in the console but, once again, **nothing** happens when I execute `system("#{default_device.adb_command} shell input keyevent KEYCODE_SEARCH")`. – Noffica Aug 05 '14 at 17:18
  • Ok, let me try this directly from console - I don't have issues when it's run from my cuke script. Also, can you validate you're touching the element prior to attempting to send text to it? Just want to be sure as this is a requirement! – lux Aug 05 '14 at 19:30
  • Yes, I do touch the search field element. Incidentally, I have not tried it directly from the script, only the console; I should try that. – Noffica Aug 06 '14 at 20:06
1

I have been able to solve this by the following command: press_user_action_button('search')

Source: https://groups.google.com/d/msg/calabash-android/Tl14BqQeWoU/zlxm3hRIpsQJ as part of the v0.5.2 release notes.

Noffica
  • 469
  • 8
  • 23
0

Try this :   system("adb shell input keyevent KEYCODE_ENTER")

By 'adb shell input keyevent', either an event_code or a string will be sent to the device.

Look into few more Event_code

Please mention your error message if you still face same issue

Community
  • 1
  • 1
Mesh
  • 193
  • 1
  • 7
  • That's actually the problem. I've tried `system("adb shell input keyevent KEYCODE_ENTER")` and I've also tried `system("adb shell input keyevent KEYCODE_SEARCH")` – Noffica Jul 24 '14 at 17:30
  • have you tried this command in console ... if yes, please post error message . – Mesh Jul 24 '14 at 17:33
  • The console does not show any error messages. It returns `true` for both. – Noffica Jul 24 '14 at 17:40
  • 1.have you done start_test_server_in_background ? 2. when you hit that command , does keypad displayed on device screen ? . – Mesh Jul 24 '14 at 17:45
  • `system("adb shell input keyevent KEYCODE_ENTER")` removes the focus from the search field and the typing cursor disappears. The search bar still contains the search query text but it thinks that the field is cleared, so all entries appear; also, the keyboard remains raised. – Noffica Jul 24 '14 at 17:45
  • `system("adb shell input keyevent KEYCODE_SEARCH")` also returns `true` in the console but this command actually does **nothing**. – Noffica Jul 24 '14 at 17:49
  • http://developer.android.com/reference/android/view/KeyEvent.html check in this link if anything works for you – Mesh Jul 24 '14 at 17:56