From cb33821c6f1f6f21d99d6d6f78214eadc613ab66 Mon Sep 17 00:00:00 2001 From: icrisan Date: Fri, 24 May 2019 15:43:56 +0300 Subject: [PATCH] Port 5 search tests. --- ...ck_search_engines_list_can_be_reordered.py | 84 ++++++++++ ..._search_engines_can_be_disabled_enabled.py | 155 ++++++++++++++++++ ...rch_engines_can_be_removed_and_restored.py | 126 ++++++++++++++ tests/firefox/search/remove_search_engine.py | 56 +++++++ ...t_click_on_a_suggestion_from_awesomebar.py | 61 +++++++ 5 files changed, 482 insertions(+) create mode 100644 tests/firefox/search/one_click_search_engines_list_can_be_reordered.py create mode 100644 tests/firefox/search/one_off_search_engines_can_be_disabled_enabled.py create mode 100644 tests/firefox/search/one_off_search_engines_can_be_removed_and_restored.py create mode 100644 tests/firefox/search/remove_search_engine.py create mode 100644 tests/firefox/search/right_click_on_a_suggestion_from_awesomebar.py diff --git a/tests/firefox/search/one_click_search_engines_list_can_be_reordered.py b/tests/firefox/search/one_click_search_engines_list_can_be_reordered.py new file mode 100644 index 00000000..7285fb5a --- /dev/null +++ b/tests/firefox/search/one_click_search_engines_list_can_be_reordered.py @@ -0,0 +1,84 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + + +from targets.firefox.fx_testcase import * + + +class Test(FirefoxTest): + + @pytest.mark.details( + description='The list of one-click search engines can be reordered.', + locale=['en-US'], + test_case_id='4277', + test_suite_id='83', + ) + def run(self, firefox): + change_search_settings_pattern = Pattern('change_search_settings.png').similar(0.6) + about_preferences_search_page_pattern = Pattern('about_preferences_search_page.png').similar(0.6) + amazon_search_bar_pattern = Pattern('amazon_search_bar.png') + bing_search_bar_pattern = Pattern('bing_search_bar.png') + search_engine_pattern = Pattern('search_engine.png') + amazon_bing_pattern = Pattern('amazon_bing.png') + amazon_bing_location_bar_pattern = Pattern('amazon_bing_location_bar.png').similar(0.6) + amazon_bing_content_search_pattern = Pattern('amazon_bing_content_search.png') + google_logo_content_search_field_pattern = Pattern('google_logo_content_search_field.png') + amazon_bing_search_bar_pattern = Pattern('amazon_bing_search_bar.png').similar(0.6) + + # Enable the search bar. + change_preference('browser.search.widget.inNavBar', True) + + select_search_bar() + type(Key.DOWN) + + expected = exists(change_search_settings_pattern, 10) + assert expected is True, 'The \'Change Search Settings\' button found in the page.' + + click(change_search_settings_pattern) + + expected = exists(about_preferences_search_page_pattern, 10) + assert expected is True, 'The \'about:preferences#search\' page opened.' + + # Select a search engine from the One-click search engines list and and move its position up in the list via + # drag & drop. + time.sleep(Settings.DEFAULT_UI_DELAY) + paste('one-click') + + expected = exists(search_engine_pattern, 10) + assert expected is True, 'The \'One-Click Search Engines\' section found.' + + expected = exists(amazon_search_bar_pattern, 10) + assert expected is True, 'The \'Amazon\' search engine found in the page.' + + expected = exists(bing_search_bar_pattern, 10) + assert expected is True, 'The \'Bing\' search engine found in the page.' + + drag_drop(amazon_search_bar_pattern, bing_search_bar_pattern, duration=0.5) + + expected = exists(amazon_bing_pattern, 10) + assert expected is True, 'The drag and drop successfully performed.' + + # Open the drop down menu from the search fields available in about:newtab and from the Search Bar. + new_tab() + select_location_bar() + paste('test') + + expected = exists(amazon_bing_location_bar_pattern, 10) + assert expected is True, 'The search engine is placed correctly in location bar.' + + new_tab() + expected = exists(google_logo_content_search_field_pattern, 10) + assert expected is True, 'Google logo from content search field found.' + + click(google_logo_content_search_field_pattern) + type(Key.DOWN) + + expected = exists(amazon_bing_content_search_pattern, 10) + assert expected is True, 'The search engine is placed correctly in content search field.' + + select_search_bar() + type(Key.DOWN) + + expected = exists(amazon_bing_search_bar_pattern, 10) + assert expected is True, 'The search engine is placed correctly in search bar.' diff --git a/tests/firefox/search/one_off_search_engines_can_be_disabled_enabled.py b/tests/firefox/search/one_off_search_engines_can_be_disabled_enabled.py new file mode 100644 index 00000000..ec14fd6f --- /dev/null +++ b/tests/firefox/search/one_off_search_engines_can_be_disabled_enabled.py @@ -0,0 +1,155 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + + +from targets.firefox.fx_testcase import * + + +class Test(FirefoxTest): + + @pytest.mark.details( + description='Items from the list of one-click search engines can be disabled and enabled.', + locale=['en-US'], + test_case_id='4275', + test_suite_id='83', + ) + def run(self, firefox): + change_search_settings_pattern = Pattern('change_search_settings.png').similar(0.6) + about_preferences_search_page_pattern = Pattern('about_preferences_search_page.png').similar(0.6) + amazon_search_bar_pattern = Pattern('amazon_search_bar.png') + bing_search_bar_pattern = Pattern('bing_search_bar.png') + duckduckgo_search_bar_pattern = Pattern('duckduckgo_search_bar.png') + search_engine_pattern = Pattern('search_engine.png') + check_engine_pattern = Pattern('check_engine.png').similar(0.6) + test_search_bing_pattern = Pattern('test_search_bing.png') + + # Enable the search bar. + change_preference('browser.search.widget.inNavBar', True) + + pattern_list = [amazon_search_bar_pattern, bing_search_bar_pattern, duckduckgo_search_bar_pattern] + + # Navigate to the 'about:preferences#search' page. + select_search_bar() + type(Key.DOWN) + + expected = exists(change_search_settings_pattern, Settings.FIREFOX_TIMEOUT) + assert expected is True, 'The \'Change Search Settings\' button found in the page.' + + click(change_search_settings_pattern) + + expected = exists(about_preferences_search_page_pattern, Settings.FIREFOX_TIMEOUT) + assert expected is True, 'The \'about:preferences#search\' page opened.' + + # Deselect several search engines from the One-click search engines list. + paste('one-click') + + expected = exists(search_engine_pattern, Settings.FIREFOX_TIMEOUT) + assert expected is True, 'The \'One-Click Search Engines\' section found.' + + expected = exists(check_engine_pattern, Settings.FIREFOX_TIMEOUT) + assert expected is True, 'The check engine pattern found in the page.' + + region_int = Screen.LEFT_THIRD + region = region_int.middle_third_horizontal() + + while region.exists(check_engine_pattern, Settings.FIREFOX_TIMEOUT): + click(check_engine_pattern) + time.sleep(Settings.DEFAULT_UI_DELAY) + + try: + expected = wait_vanish(check_engine_pattern, Settings.DEFAULT_UI_DELAY, region) + assert expected is True, 'Each search engine is unchecked.' + except FindError: + raise FindError('There are search engines still checked.') + + # Perform a search from a new tab and a private window. + # Check that the unchecked search engines are no longer displayed in the search bar, one-offs list. + new_tab() + + select_search_bar() + type(Key.DOWN) + + for i in range(pattern_list.__len__()): + try: + expected = wait_vanish(pattern_list[i], Settings.FIREFOX_TIMEOUT) + assert expected is True, 'Element found at position ' + i.__str__() + ' in the list not found.' + + except FindError: + raise FindError('Element found at position ' + i.__str__() + ' in the list found.') + + new_private_window() + + select_search_bar() + type(Key.DOWN) + + for i in range(pattern_list.__len__()): + try: + expected = wait_vanish(pattern_list[i], Settings.FIREFOX_TIMEOUT) + assert expected is True, 'Element found at position ' + i.__str__() + ' in the list not found.' + + except FindError: + raise FindError('Element found at position ' + i.__str__() + ' in the list found.') + + close_window() + + # Select again 'Change Search Settings' and enable back the search engines. + select_search_bar() + type(Key.DOWN) + + click(change_search_settings_pattern) + + expected = exists(about_preferences_search_page_pattern, Settings.FIREFOX_TIMEOUT) + assert expected is True, 'The \'about:preferences#search\' page opened.' + + type(Key.TAB) + + click(amazon_search_bar_pattern.target_offset(-15, 5)) + time.sleep(Settings.DEFAULT_UI_DELAY) + + click(bing_search_bar_pattern.target_offset(-15, 5)) + time.sleep(Settings.DEFAULT_UI_DELAY) + + click(duckduckgo_search_bar_pattern.target_offset(-15, 5)) + time.sleep(Settings.DEFAULT_UI_DELAY) + + # Repeat the above steps to see that the search engines are restored. + region = Screen.UPPER_RIGHT_CORNER + + new_tab() + + select_search_bar() + paste('test') + + for i in range(pattern_list.__len__()): + try: + expected = region.exists(pattern_list[i], Settings.FIREFOX_TIMEOUT) + assert expected is True, 'Element found at position ' + i.__str__() + ' in the list found.' + + except FindError: + raise FindError('Element found at position ' + i.__str__() + ' in the list not found.') + + new_private_window() + + select_search_bar() + type(Key.DOWN) + + for i in range(pattern_list.__len__()): + try: + expected = region.exists(pattern_list[i], 10) + assert expected is True, 'Element found at position ' + i.__str__() + ' in the list found.' + + except FindError: + raise FindError('Element found at position ' + i.__str__() + ' in the list not found.') + + close_window() + + # Perform a search using a restored one-off search engine. + type(Key.DOWN) + + region.click(bing_search_bar_pattern) + + time.sleep(Settings.DEFAULT_UI_DELAY) + + expected = exists(test_search_bing_pattern, Settings.FIREFOX_TIMEOUT) + assert expected is True, 'The search is performed with the Bing engine.' diff --git a/tests/firefox/search/one_off_search_engines_can_be_removed_and_restored.py b/tests/firefox/search/one_off_search_engines_can_be_removed_and_restored.py new file mode 100644 index 00000000..4188a639 --- /dev/null +++ b/tests/firefox/search/one_off_search_engines_can_be_removed_and_restored.py @@ -0,0 +1,126 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + + +from targets.firefox.fx_testcase import * + + +class Test(FirefoxTest): + + @pytest.mark.details( + description='Items from the list of one-click search engines can be removed and restored.', + locale=['en-US'], + test_case_id='4276', + test_suite_id='83', + ) + def run(self, firefox): + change_search_settings_pattern = Pattern('change_search_settings.png').similar(0.6) + about_preferences_search_page_pattern = Pattern('about_preferences_search_page.png').similar(0.6) + search_engine_pattern = Pattern('search_engine.png') + amazon_search_bar_pattern = Pattern('amazon_search_bar.png') + remove_pattern = Pattern('remove.png') + restore_default_search_engine_pattern = Pattern('restore_default_search_engine.png') + + # Enable the search bar. + change_preference('browser.search.widget.inNavBar', True) + + # Navigate to the 'about:preferences#search' page. + select_search_bar() + type(Key.DOWN) + + expected = exists(amazon_search_bar_pattern, 10) + assert expected is True, 'The \'Amazon\' search engine found in the one-offs list.' + + expected = exists(change_search_settings_pattern, 10) + assert expected is True, 'The \'Change Search Settings\' button found in the page.' + + click(change_search_settings_pattern) + + expected = exists(about_preferences_search_page_pattern, 10) + assert expected is True, 'The \'about:preferences#search\' page opened.' + + # Select a search engine from the One-click search engines list and click the Remove button. + paste('one-click') + + expected = exists(search_engine_pattern, 10) + assert expected is True, 'The \'One-Click Search Engines\' section found.' + + expected = exists(amazon_search_bar_pattern, 10) + assert expected is True, 'The \'Amazon\' search engine found in the \'about:preferences#search\' page.' + + click(amazon_search_bar_pattern) + + expected = exists(remove_pattern, 10) + assert expected is True, 'The \'Remove\' button found.' + + click(remove_pattern) + + try: + expected = wait_vanish(amazon_search_bar_pattern, 10) + assert expected is True, 'The \'Amazon\' search engine is removed from the the ' \ + '\'about:preferences#search\' page.' + except FindError: + raise FindError('The \'Amazon\' search engine is still displayed in the page.') + + # Open the drop down menu from the Search Bar and check that the search engine previously removed is no longer + # displayed in the one-offs list. + select_search_bar() + type(Key.DOWN) + + expected = exists(amazon_search_bar_pattern, 3) + assert expected is False, 'The search engine previously removed is no longer displayed in the list.' + + # Open a new tab and a private window and repeat the above step. + new_tab() + select_search_bar() + type(Key.DOWN) + + expected = exists(amazon_search_bar_pattern, 3) + assert expected is False, 'The search engine previously removed is no longer displayed in the list.' + + new_private_window() + select_search_bar() + type(Key.DOWN) + + expected = exists(amazon_search_bar_pattern, 3) + assert expected is False, 'The search engine previously removed is no longer displayed in the list.' + + close_window() + + # Select again 'Change Search Settings' and add back the previously removed search engine by selecting + # "Restore Default Search Engines". + select_search_bar() + type(Key.DOWN) + + click(change_search_settings_pattern) + + expected = exists(about_preferences_search_page_pattern, 10) + assert expected is True, 'The \'about:preferences#search\' page loaded.' + + type(Key.TAB) + + expected = exists(restore_default_search_engine_pattern, 10) + assert expected is True, 'The \'Restore Default Search Engines\' button found.' + + click(restore_default_search_engine_pattern) + + expected = exists(amazon_search_bar_pattern, 10) + assert expected is True, 'The search engine previously removed is placed back in the list.' + + # Repeat the above steps to see that the search engine is restored. + new_tab() + select_search_bar() + type(Key.DOWN) + + expected = exists(amazon_search_bar_pattern, 3) + assert expected is True, 'The search engine is restored.' + + new_private_window() + select_search_bar() + type(Key.DOWN) + + expected = exists(amazon_search_bar_pattern, 3) + assert expected is True, 'The search engine is restored.' + + close_window() diff --git a/tests/firefox/search/remove_search_engine.py b/tests/firefox/search/remove_search_engine.py new file mode 100644 index 00000000..8a7049dc --- /dev/null +++ b/tests/firefox/search/remove_search_engine.py @@ -0,0 +1,56 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + + +from targets.firefox.fx_testcase import * + + +class Test(FirefoxTest): + + @pytest.mark.details( + description='Removing search engines from preferences disabled \'Restore defaults\' button.', + locale=['en-US'], + test_case_id='111378', + test_suite_id='83', + ) + def run(self, firefox): + about_preferences_search_page_pattern = Pattern('about_preferences_search_page.png').similar(0.6) + wikipedia_search_bar_pattern = Pattern('wikipedia_search_bar.png') + restore_default_search_engine_pattern = Pattern('restore_default_search_engine.png') + remove_pattern = Pattern('remove.png') + + navigate('about:preferences#search') + + expected = exists(about_preferences_search_page_pattern, 10) + assert expected is True, 'The \'about:preferences#search\' page successfully loaded.' + + paste('one-click') + + expected = exists(wikipedia_search_bar_pattern, 10) + assert expected is True, 'The \'Wikipedia\' search engine is visible.' + + click(wikipedia_search_bar_pattern) + + try: + wait(remove_pattern, 10) + logger.debug('The \'Remove\' button is enabled.') + except FindError: + raise FindError('The \'Remove\' button is not enabled.') + + for i in range(3): + click(remove_pattern) + + expected = exists(wikipedia_search_bar_pattern, 3) + assert expected is False, 'The \'Wikipedia\' search engine is removed.' + + try: + wait(restore_default_search_engine_pattern, 10) + logger.debug('The \'Restore Default Search Engines\' button is enabled.') + except FindError: + raise FindError('The \'Restore Default Search Engines\' button is not enabled.') + + click(restore_default_search_engine_pattern) + + expected = exists(wikipedia_search_bar_pattern, 10) + assert expected is True, 'The \'Wikipedia\' search engine is restored.' diff --git a/tests/firefox/search/right_click_on_a_suggestion_from_awesomebar.py b/tests/firefox/search/right_click_on_a_suggestion_from_awesomebar.py new file mode 100644 index 00000000..e4ed6796 --- /dev/null +++ b/tests/firefox/search/right_click_on_a_suggestion_from_awesomebar.py @@ -0,0 +1,61 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + + +from targets.firefox.fx_testcase import * + + +class Test(FirefoxTest): + + @pytest.mark.details( + description='Right click on a result from Awesomebar closes the dropdown.', + locale=['en-US'], + test_case_id='111375', + test_suite_id='83', + ) + def run(self, firefox): + wikipedia_search_bar_pattern = Pattern('wikipedia_search_bar.png').similar(0.6) + mozilla_suggestion_pattern = Pattern('mozilla_suggestion.png') + test_bold_pattern = Pattern('test_bold.png') + + # Enable the search bar. + change_preference('browser.search.widget.inNavBar', True) + + navigate(LocalWeb.MOZILLA_TEST_SITE) + + expected = exists(LocalWeb.MOZILLA_LOGO, 10) + assert expected is True, 'Mozilla page loaded successfully.' + + # Check that the dropdown stays open after right clicking on a suggestion from the location bar. + select_location_bar() + paste('127.0.0.1') + + expected = exists(wikipedia_search_bar_pattern, 10) + assert expected is True, 'Wikipedia one off is successfully displayed.' + + expected = exists(mozilla_suggestion_pattern, 10) + assert expected is True, 'Search suggestions successfully displayed.' + + right_click(mozilla_suggestion_pattern) + + expected = exists(wikipedia_search_bar_pattern, 10) + assert expected is True, 'The dropdown stays open after right clicking on a suggestion from the location bar.' + + # Check that the dropdown stays open after right clicking on a suggestion from the search bar. + select_search_bar() + paste('test') + + expected = exists(wikipedia_search_bar_pattern, 10) + assert expected is True, 'Wikipedia one off is successfully displayed.' + + region_int = Screen.UPPER_RIGHT_CORNER + region = region_int.middle_third_horizontal() + + expected = region.exists(test_bold_pattern, 10) + assert expected is True, 'Search suggestions are shown for the input in question.' + + region.right_click(test_bold_pattern, 1) + + expected = exists(wikipedia_search_bar_pattern, 10) + assert expected is True, 'The dropdown stays open after right clicking on a suggestion from search bar.'