diff --git a/manifests/all.yaml b/manifests/all.yaml index 0b2d6b706..6179e95b1 100644 --- a/manifests/all.yaml +++ b/manifests/all.yaml @@ -43,6 +43,7 @@ address_bar_and_search: - test_switch_to_existing_tab_when_having_the_same_URL - test_search_suggestions - test_delete_history_entry_via_firefox_suggest_completion_list +- test_searchmode_update_on_alias_prefix audio_video: - test_block_audio_video_functionality - test_allow_audio_video_functionality diff --git a/manifests/functional.yaml b/manifests/functional.yaml index 7c1632977..d1fa704fb 100644 --- a/manifests/functional.yaml +++ b/manifests/functional.yaml @@ -8,6 +8,7 @@ address_bar_and_search: - test_searchmode_cleared_on_engine_removal - test_switch_to_existing_tab_when_having_the_same_URL - test_delete_history_entry_via_firefox_suggest_completion_list +- test_searchmode_update_on_alias_prefix tabs: - test_change_position_of_pinned_tabs diff --git a/manifests/key.yaml b/manifests/key.yaml index 8248a3dcd..5d32f43c9 100644 --- a/manifests/key.yaml +++ b/manifests/key.yaml @@ -42,6 +42,7 @@ address_bar_and_search: test_searchbar_results_shown_in_a_new_tab: pass test_searchmode_change_tab: pass test_searchmode_cleared_on_engine_removal: pass + test_searchmode_update_on_alias_prefix : pass test_server_not_found_error: pass test_server_not_found_error_pb: pass test_suggestion_engine_selection: pass diff --git a/modules/browser_object_navigation.py b/modules/browser_object_navigation.py index da5d00d3b..297fcf614 100644 --- a/modules/browser_object_navigation.py +++ b/modules/browser_object_navigation.py @@ -84,10 +84,20 @@ def clear_awesome_bar(self) -> BasePage: return self @BasePage.context_chrome - def type_in_awesome_bar(self, term: str) -> BasePage: - """Enter text into the Awesome Bar. You probably want self.search()""" - self.set_awesome_bar() - self.awesome_bar.click() + def type_in_awesome_bar(self, term: str, reset=True) -> BasePage: + """ + Type text into the Awesome Bar. + + reset=True (default): refocuses and clicks the Awesome Bar before typing, + which moves the cursor to the end. + + reset=False: keeps the current cursor position (useful when tests manually + move the caret with arrow keys). + """ + if reset: + self.set_awesome_bar() + self.awesome_bar.click() + self.awesome_bar.send_keys(term) return self diff --git a/tests/address_bar_and_search/test_searchmode_update_on_alias_prefix.py b/tests/address_bar_and_search/test_searchmode_update_on_alias_prefix.py new file mode 100644 index 000000000..a0196c3bc --- /dev/null +++ b/tests/address_bar_and_search/test_searchmode_update_on_alias_prefix.py @@ -0,0 +1,40 @@ +import pytest +from selenium.webdriver import Firefox, Keys + +from modules.browser_object_navigation import Navigation + +ENGINE_KEYWORD = "@bing" +TEXT = "QA" +ENGINE = "Bing" + + +@pytest.fixture() +def test_case(): + return "3028841" + + +def test_searchmode_update_on_alias_prefix(driver: Firefox): + """ + C3028841 - Search mode is updated after typing a keyword/alias at the beginning of a non-empty search string + """ + + # Instantiate object + nav = Navigation(driver) + + # TODO: Go to about:preferences#search and set a keyword for bing, for example: bang + + # Open a new tab, focus the urlbar and enter any string + nav.type_in_awesome_bar(TEXT) + + # Start pressing LEFT KEY on the keyboard so the text insertion cursor is at the beginning + for _ in range(2): + nav.perform_key_combo_chrome(Keys.LEFT) + + # Type @bing and press SPACE + nav.type_in_awesome_bar(ENGINE_KEYWORD, reset=False) + nav.perform_key_combo_chrome(Keys.SPACE) + + # Search shortcut should be identified and translated to search mode for bing with the original text + # remaining as search query + nav.verify_engine_returned(ENGINE) + nav.verify_plain_text_in_input_awesome_bar(TEXT)