from behave import when, then from helpers.appium.keyboard import hide_keyboard @when('I search for "{search_term}"') def step_impl(context, search_term): context.search_screen.search(search_term, wait_for_results=False) hide_keyboard(context.driver) @when('I search for a non-existing item "{search_term}"') def step_impl(context, search_term): context.search_screen.search(search_term, wait_for_results=False) hide_keyboard(context.driver) @when("I use the chart screen's search to look for '{search_term}'") def step_impl(context, search_term): context.charts_digest_screen.search_via_chart_screen_header(search_term) @then('I can see product {product} with id {product_id} in my search results') def step_impl(context, product, product_id): context.search_screen.assert_product(product_id) @then('I can see artist {artist} with id {artist_id} in my search results') def step_impl(context, artist, artist_id): context.search_screen.assert_artist(artist, artist_id) @then('I can see song {song} with id {song_id} in my search results') def step_impl(context, song, song_id): context.search_screen.assert_song(song, song_id) @then('I should see artist {artist} with id {artist_id} ' 'in the list of recent searches') def step_impl(context, artist, artist_id): context.search_screen.assert_artist_in_recent_search(artist, artist_id) @then('I should see song {song} with id {song_id} ' 'in the list of recent searches') def step_impl(context, song, song_id): context.search_screen.assert_song_in_recent_search(song, song_id) @then('I should see product {product} with id {product_id} ' 'in the list of recent searches') def step_impl(context, product, product_id): context.search_screen.assert_product_in_recent_search(product_id) @when('I filter by {category} {search_term}') @then('I filter by {category} {search_term}') def step_impl(context, category, search_term): context.home_screen.filter(category, search_term) @when('I clear the search field') @then('I clear the search field') def step_impl(context): context.search_screen.clear_search_field() @when('I clear recent search results') def step_impl(context): context.search_screen.clear_recent_results() @then('I should see no recent results') def step_impl(context): context.search_screen.verify_no_recent_results_visible()