JDaRiva
JDaRiva

Reputation: 9

Push on Android search button with Calabash

I have this problem: I'm testing an Android app who's using a search box embedded in an Edit Text, so it's not a typical "search" controller but in the keyboard the search button appear. I'm using Calabash to write the tests.

This is the test:

Scenario: Iniciar la aplicación y realizar búsquedas
 And I wait for "Música" to appear
 Then I press view with id "menu_search"
 Then I enter text "Judas Priest" into field with id "collapsibleEditText"
 Then I press "search"    

The execution return this error:

And I wait for "Música" to appear
Then I press view with id "menu_search"
Then I enter text "Judas Priest" into field with id "collapsibleEditText"
Then I press "search" 
  Timeout waiting for elements: * marked:'search' (Calabash::Android::WaitHelpers::WaitError)
  features/test.feature:11:in `Then I press "search"'

Upvotes: 1

Views: 690

Answers (3)

JDaRiva
JDaRiva

Reputation: 9

I copy the fix to the problem.

I've create a new step definition in my scenary

Scenario
    .... nothing changed from the question above
    Then I press search button

And in the features/step_definitions/calabash_steps.rb

Then /^I press search button$/ do
  press_enter_button
end

And it works

Upvotes: -2

Tobias
Tobias

Reputation: 678

You should use the method press_user_action_button to press the 'search' button appearing on the keyboard. Pressing the enter key (press_enter_key) is not what a user would do, unless the device has a physical keyboard. You can read more about how Android is handling the special keyboard 'enter keys' (user action buttons) here.

Upvotes: 4

Lasse
Lasse

Reputation: 1163

With the step "Then I press "search"" it will search for UI elements with that label. But that does not include the keyboard.

There are 2 options

  1. Something like

    Then /^I press the enter button$/

  2. Or something like this

    keyboard_enter_keyevent('KEYCODE_ENTER')

(This is copied from Krazy Robot)

Upvotes: 0

Related Questions