From c7c33d6a76dc960dcf78717692a678817f944b81 Mon Sep 17 00:00:00 2001 From: soncuteanca Date: Tue, 16 Sep 2025 15:45:58 +0300 Subject: [PATCH 01/11] Refactor clear history tests --- modules/browser_object_panel_ui.py | 44 ++++++++----------- .../test_clear_all_history.py | 21 ++++++--- .../test_clear_recent_history_displayed.py | 9 ++-- 3 files changed, 39 insertions(+), 35 deletions(-) diff --git a/modules/browser_object_panel_ui.py b/modules/browser_object_panel_ui.py index 4b9d30c8b..351fea63e 100644 --- a/modules/browser_object_panel_ui.py +++ b/modules/browser_object_panel_ui.py @@ -163,19 +163,27 @@ def open_history_menu(self) -> BasePage: self.click_on("panel-ui-history") return self - def select_clear_history_option(self, option: str) -> BasePage: + @BasePage.context_chrome + def open_clear_history_dialog(self) -> BasePage: + """Opens the clear history dialog and switches to iframe context""" + self.open_history_menu() + self.element_clickable("clear-recent-history") + self.click_on("clear-recent-history") + + self.element_visible("iframe") + iframe = self.get_element("iframe") + BrowserActions(self.driver).switch_to_iframe_context(iframe) + return self + + @BasePage.context_content + def select_history_time_range_option(self, option: str) -> BasePage: """ - Selects the clear history option, assumes the history panel is open. + Selects time range option (assumes already in iframe context) """ - with self.driver.context(self.driver.CONTEXT_CHROME): - self.get_element("clear-recent-history").click() - iframe = self.get_element("iframe") - BrowserActions(self.driver).switch_to_iframe_context(iframe) - - with self.driver.context(self.driver.CONTEXT_CONTENT): - dropdown_root = self.get_element("clear-history-dropdown") - dropdown = Dropdown(page=self, root=dropdown_root, require_shadow=False) - dropdown.select_option(option) + dropdown_root = self.get_element("clear-history-dropdown") + dropdown = Dropdown(page=self, root=dropdown_root, require_shadow=False) + dropdown.select_option(option) + return self def get_all_history(self) -> List[WebElement]: """ @@ -269,20 +277,6 @@ def get_bookmark_tags(self, tags: List[str]) -> List[str]: for tag in tags ] - @BasePage.context_chrome - def clear_recent_history(self, execute=True) -> BasePage: - """Clears recent history. Case of execute=True may not be complete""" - self.open_panel_menu() - self.get_element("panel-ui-history").click() - - self.element_exists("clear-recent-history") - self.element_visible("clear-recent-history") - self.element_clickable("clear-recent-history") - if execute: - self.click("clear_recent_history") - - return self - @BasePage.context_chrome def confirm_history_clear(self): """Confirm that the history is empty""" diff --git a/tests/bookmarks_and_history/test_clear_all_history.py b/tests/bookmarks_and_history/test_clear_all_history.py index 6f1b1df4f..dd9370b08 100644 --- a/tests/bookmarks_and_history/test_clear_all_history.py +++ b/tests/bookmarks_and_history/test_clear_all_history.py @@ -19,12 +19,19 @@ def test_clear_all_history(driver: Firefox): """ C172045: Verify that the user can Clear all the History """ - gen_page = GenericPage(driver) - panel_ui = PanelUi(driver) - panel_ui.open() - panel_ui.open_history_menu() - panel_ui.select_clear_history_option("Everything") + # Instantiate objects + page = GenericPage(driver) + panel = PanelUi(driver) - gen_page.click_on("clear-history-button") - panel_ui.confirm_history_clear() + # Open Clear History menu + panel.open_clear_history_dialog() + + # Select the option to clear all the history + panel.select_history_time_range_option("Everything") + # A method in panel-ui with selectors moved accordingly would work better, limited for now due to context level + # set to chrome context while shadow parent needs content context + page.click_on("clear-history-button") + + # Verify all the history is deleted + panel.confirm_history_clear() diff --git a/tests/bookmarks_and_history/test_clear_recent_history_displayed.py b/tests/bookmarks_and_history/test_clear_recent_history_displayed.py index 894ca4c04..e7788b4fd 100644 --- a/tests/bookmarks_and_history/test_clear_recent_history_displayed.py +++ b/tests/bookmarks_and_history/test_clear_recent_history_displayed.py @@ -13,7 +13,10 @@ def test_clear_recent_history_displayed(driver: Firefox): """ C172043: Clear recent history panel displayed """ - panel_ui = PanelUi(driver) - panel_ui.open() - panel_ui.clear_recent_history(execute=False) + # Instantiate object + panel = PanelUi(driver) + + # Open Clear recent history dialog + panel.open() + panel.open_clear_history_dialog() From dc858db947c71b11adfdb532ccfbf5d720295570 Mon Sep 17 00:00:00 2001 From: soncuteanca Date: Tue, 16 Sep 2025 16:15:54 +0300 Subject: [PATCH 02/11] Add condition for timing issue --- modules/browser_object_panel_ui.py | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/browser_object_panel_ui.py b/modules/browser_object_panel_ui.py index 351fea63e..3bca9eb5b 100644 --- a/modules/browser_object_panel_ui.py +++ b/modules/browser_object_panel_ui.py @@ -167,6 +167,7 @@ def open_history_menu(self) -> BasePage: def open_clear_history_dialog(self) -> BasePage: """Opens the clear history dialog and switches to iframe context""" self.open_history_menu() + self.element_visible("clear-recent-history") self.element_clickable("clear-recent-history") self.click_on("clear-recent-history") From 5f0b6623b378153514bf3688c8047eb1610025a2 Mon Sep 17 00:00:00 2001 From: soncuteanca Date: Tue, 16 Sep 2025 17:14:56 +0300 Subject: [PATCH 03/11] New attempt --- modules/browser_object_panel_ui.py | 4 +--- tests/bookmarks_and_history/test_clear_all_history.py | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/browser_object_panel_ui.py b/modules/browser_object_panel_ui.py index 3bca9eb5b..37c47ff15 100644 --- a/modules/browser_object_panel_ui.py +++ b/modules/browser_object_panel_ui.py @@ -166,9 +166,7 @@ def open_history_menu(self) -> BasePage: @BasePage.context_chrome def open_clear_history_dialog(self) -> BasePage: """Opens the clear history dialog and switches to iframe context""" - self.open_history_menu() - self.element_visible("clear-recent-history") - self.element_clickable("clear-recent-history") + self.click_on("clear-recent-history") self.element_visible("iframe") diff --git a/tests/bookmarks_and_history/test_clear_all_history.py b/tests/bookmarks_and_history/test_clear_all_history.py index dd9370b08..505c22f63 100644 --- a/tests/bookmarks_and_history/test_clear_all_history.py +++ b/tests/bookmarks_and_history/test_clear_all_history.py @@ -24,7 +24,8 @@ def test_clear_all_history(driver: Firefox): page = GenericPage(driver) panel = PanelUi(driver) - # Open Clear History menu + # Open Clear History dialog + panel.open_history_menu() panel.open_clear_history_dialog() # Select the option to clear all the history From 53efb6d93a89b4a1938d4b06d5080ee3305cadd8 Mon Sep 17 00:00:00 2001 From: soncuteanca Date: Tue, 16 Sep 2025 17:39:29 +0300 Subject: [PATCH 04/11] Revert partially to the initial approach --- modules/browser_object_panel_ui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/browser_object_panel_ui.py b/modules/browser_object_panel_ui.py index 37c47ff15..c6b8e4113 100644 --- a/modules/browser_object_panel_ui.py +++ b/modules/browser_object_panel_ui.py @@ -167,7 +167,7 @@ def open_history_menu(self) -> BasePage: def open_clear_history_dialog(self) -> BasePage: """Opens the clear history dialog and switches to iframe context""" - self.click_on("clear-recent-history") + self.get_element("clear-recent-history").click() self.element_visible("iframe") iframe = self.get_element("iframe") From 6bfca23cf04fce40538e2076f1dc278bcbfd5ae4 Mon Sep 17 00:00:00 2001 From: soncuteanca Date: Tue, 16 Sep 2025 18:26:10 +0300 Subject: [PATCH 05/11] Use the correct method --- modules/browser_object_panel_ui.py | 5 ++--- .../test_clear_recent_history_displayed.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/browser_object_panel_ui.py b/modules/browser_object_panel_ui.py index c6b8e4113..394abed01 100644 --- a/modules/browser_object_panel_ui.py +++ b/modules/browser_object_panel_ui.py @@ -165,9 +165,8 @@ def open_history_menu(self) -> BasePage: @BasePage.context_chrome def open_clear_history_dialog(self) -> BasePage: - """Opens the clear history dialog and switches to iframe context""" - - self.get_element("clear-recent-history").click() + """Opens the clear history dialog and switches to iframe context, assuming the history panel is opened""" + self.click_on("clear-recent-history") self.element_visible("iframe") iframe = self.get_element("iframe") diff --git a/tests/bookmarks_and_history/test_clear_recent_history_displayed.py b/tests/bookmarks_and_history/test_clear_recent_history_displayed.py index e7788b4fd..2cec4ea3c 100644 --- a/tests/bookmarks_and_history/test_clear_recent_history_displayed.py +++ b/tests/bookmarks_and_history/test_clear_recent_history_displayed.py @@ -18,5 +18,5 @@ def test_clear_recent_history_displayed(driver: Firefox): panel = PanelUi(driver) # Open Clear recent history dialog - panel.open() + panel.open_history_menu() panel.open_clear_history_dialog() From 112225183aedf8e689d4e891dd1111155b513ad4 Mon Sep 17 00:00:00 2001 From: soncuteanca Date: Tue, 16 Sep 2025 20:04:51 +0300 Subject: [PATCH 06/11] Add open website from history test --- modules/browser_object_panel_ui.py | 46 ++++++++++++++++++- .../test_open_websites_from_history.py | 37 ++++----------- 2 files changed, 55 insertions(+), 28 deletions(-) diff --git a/modules/browser_object_panel_ui.py b/modules/browser_object_panel_ui.py index 394abed01..a7e949e17 100644 --- a/modules/browser_object_panel_ui.py +++ b/modules/browser_object_panel_ui.py @@ -1,6 +1,8 @@ +import random from time import sleep -from typing import List +from typing import List, Tuple +import pytest from pypom import Region from selenium.common.exceptions import NoSuchElementException, TimeoutException from selenium.webdriver.remote.webelement import WebElement @@ -191,6 +193,48 @@ def get_all_history(self) -> List[WebElement]: history_items = self.get_elements("bookmark-item") return history_items + @BasePage.context_chrome + def get_random_history_entry(self) -> Tuple[str, str]: + """ + Retrieve a random browser history entry from the Panel UI. + + This method ensures the History submenu is open, fetches all available + history items, selects one at random, extracts its URL and title, and + returns them after validating both are usable. + """ + items = self.get_elements("bookmark-item") + + if not items: + pytest.skip("No history available to test.") + + item = random.choice(items) + raw_url = item.get_attribute("image") + label = item.get_attribute("label") + + trimmed_url = self._extract_url_from_history(raw_url) + assert trimmed_url and label, "History item has missing URL or label." + + return trimmed_url, label + + def _extract_url_from_history(self, raw_url: str) -> str: + """ + Extract a valid HTTP(S) URL from a raw history image attribute. + + Firefox stores history URLs using special schemes like: + 'moz-anno:favicon:https://example.com' + This method locates the first occurrence of "http" and returns the substring from there. + + Args: + raw_url (str): The raw string value from the 'image' attribute of a history entry. + """ + if not raw_url: + return "" + + if "http" in raw_url: + return raw_url[raw_url.find("http") :] + + return raw_url.strip() + @BasePage.context_chrome def redirect_to_about_logins_page(self) -> BasePage: """ diff --git a/tests/bookmarks_and_history/test_open_websites_from_history.py b/tests/bookmarks_and_history/test_open_websites_from_history.py index 89693b6eb..b6711b79f 100644 --- a/tests/bookmarks_and_history/test_open_websites_from_history.py +++ b/tests/bookmarks_and_history/test_open_websites_from_history.py @@ -1,5 +1,3 @@ -import random - import pytest from selenium.webdriver import Firefox @@ -17,35 +15,20 @@ def use_profile(): return "theme_change" -def trim_url(url: str) -> str: - colon_index = url.find(":") - if colon_index != -1: - return url[colon_index + 1 :].strip() - else: - return "" - - def test_open_websites_from_history(driver: Firefox): """ - C118807: Verify that the user can open websites from the Toolbar History submenu + C118807: Verify that the user can open any random website from Hamburger Menu, History section """ - panel_ui = PanelUi(driver) - panel_ui.open() - panel_ui.open_history_menu() + # Instantiate objects + panel = PanelUi(driver) + panel.open_history_menu() - with driver.context(driver.CONTEXT_CHROME): - history_items = panel_ui.get_all_history() - if len(history_items) == 0: - assert False, "There is no history." + # Retrieve a random item from history and its label + url, label = panel.get_random_history_entry() - rand_index = random.randint(0, len(history_items) - 1) - url_to_visit = history_items[rand_index].get_attribute("image") - website_label = history_items[rand_index].get_attribute("label") - - trimmed_url = trim_url(url_to_visit) - page = GenericPage(driver, url=trimmed_url) + # Open the corresponding page and verify URL and title match + page = GenericPage(driver, url=url) page.open() - - page.url_contains(trimmed_url) - page.title_contains(website_label) + page.url_contains(url) + page.title_contains(label) From 1ca81a5100562e6b0c5aa1421aa74df70979a00b Mon Sep 17 00:00:00 2001 From: soncuteanca Date: Tue, 16 Sep 2025 21:19:32 +0300 Subject: [PATCH 07/11] Replace pytest.skip due to ci headed failures --- modules/browser_object_panel_ui.py | 7 +++---- .../test_open_websites_from_history.py | 10 +++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/browser_object_panel_ui.py b/modules/browser_object_panel_ui.py index a7e949e17..efc9ed137 100644 --- a/modules/browser_object_panel_ui.py +++ b/modules/browser_object_panel_ui.py @@ -1,8 +1,7 @@ import random from time import sleep -from typing import List, Tuple +from typing import List, Optional, Tuple -import pytest from pypom import Region from selenium.common.exceptions import NoSuchElementException, TimeoutException from selenium.webdriver.remote.webelement import WebElement @@ -194,7 +193,7 @@ def get_all_history(self) -> List[WebElement]: return history_items @BasePage.context_chrome - def get_random_history_entry(self) -> Tuple[str, str]: + def get_random_history_entry(self) -> Optional[Tuple[str, str]]: """ Retrieve a random browser history entry from the Panel UI. @@ -205,7 +204,7 @@ def get_random_history_entry(self) -> Tuple[str, str]: items = self.get_elements("bookmark-item") if not items: - pytest.skip("No history available to test.") + return None item = random.choice(items) raw_url = item.get_attribute("image") diff --git a/tests/bookmarks_and_history/test_open_websites_from_history.py b/tests/bookmarks_and_history/test_open_websites_from_history.py index b6711b79f..a3f51bea2 100644 --- a/tests/bookmarks_and_history/test_open_websites_from_history.py +++ b/tests/bookmarks_and_history/test_open_websites_from_history.py @@ -1,3 +1,5 @@ +import logging + import pytest from selenium.webdriver import Firefox @@ -24,8 +26,14 @@ def test_open_websites_from_history(driver: Firefox): panel = PanelUi(driver) panel.open_history_menu() + result = panel.get_random_history_entry() + + if result is None: + logging.info("Test skipped: No history available") + return + # Retrieve a random item from history and its label - url, label = panel.get_random_history_entry() + url, label = result # Open the corresponding page and verify URL and title match page = GenericPage(driver, url=url) From 85522c9300b1191fa72905c7f3deb8378af235f7 Mon Sep 17 00:00:00 2001 From: soncuteanca Date: Wed, 17 Sep 2025 16:37:33 +0300 Subject: [PATCH 08/11] Add 172045 test --- .../test_clear_all_history.py | 3 +- ...e_in_new_tab_present_in_toolbar_history.py | 40 ++++++++----------- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/tests/bookmarks_and_history/test_clear_all_history.py b/tests/bookmarks_and_history/test_clear_all_history.py index 505c22f63..795876ba6 100644 --- a/tests/bookmarks_and_history/test_clear_all_history.py +++ b/tests/bookmarks_and_history/test_clear_all_history.py @@ -30,8 +30,7 @@ def test_clear_all_history(driver: Firefox): # Select the option to clear all the history panel.select_history_time_range_option("Everything") - # A method in panel-ui with selectors moved accordingly would work better, limited for now due to context level - # set to chrome context while shadow parent needs content context + # A method in panel-ui with selectors moved accordingly would work better, I'll come to this later, couldn't make it work so far page.click_on("clear-history-button") # Verify all the history is deleted diff --git a/tests/bookmarks_and_history/test_opened_website_in_new_tab_present_in_toolbar_history.py b/tests/bookmarks_and_history/test_opened_website_in_new_tab_present_in_toolbar_history.py index 986f80bb1..ffc294afe 100644 --- a/tests/bookmarks_and_history/test_opened_website_in_new_tab_present_in_toolbar_history.py +++ b/tests/bookmarks_and_history/test_opened_website_in_new_tab_present_in_toolbar_history.py @@ -10,37 +10,29 @@ def test_case(): return "118802" -FACEBOOK_URL = "https://www.facebook.com/" -AMAZON_URL = "https://www.amazon.com/" -YOUTUBE_URL = "https://www.youtube.com/" +@pytest.fixture() +def use_profile(): + return "theme_change" + -WEBSITES = [FACEBOOK_URL, AMAZON_URL] +ETSY_URL = "https://www.etsy.com/" def test_the_website_opened_in_new_tab_is_present_in_history_menu(driver: Firefox): """ - C118802 - Verify that the website opened in new tab is displayed in the Toolbar History submenu on top of the + C118802 - Verify that the website opened in new tab is displayed in Hamburger Menu, History section, on top of the list """ - - for url in WEBSITES: - GenericPage(driver, url=url).open() - + # Instantiate objects tabs = TabBar(driver) + page = GenericPage(driver, url=ETSY_URL) + panel = PanelUi(driver) - tabs.new_tab_by_button() - tabs.wait_for_num_tabs(2) - tabs.switch_to_new_tab() - - page = GenericPage(driver, url=YOUTUBE_URL) - page.open() - page.url_contains("youtube") - - panel_ui = PanelUi(driver) - panel_ui.open() - panel_ui.open_history_menu() + # Open a new tab, switch to it and verify is the url contains the desired domain + tabs.open_web_page_in_new_tab(page, 2) + page.url_contains("etsy") - # Verify YouTube is present in the history menu and is on top of the list as the most recent website visited - panel_ui.expect_element_attribute_contains( - "recent-history-content", "value", "YouTube" - ) + # Verify Etsy is present in the Hamburger Menu, History section and is on top of the list as the most recent + # website visited + panel.open_history_menu() + panel.expect_element_attribute_contains("recent-history-content", "value", "Etsy") From b896e7db1eb5bbb6df3761725b4b6290693f4d35 Mon Sep 17 00:00:00 2001 From: soncuteanca Date: Wed, 17 Sep 2025 18:25:30 +0300 Subject: [PATCH 09/11] Add 118805, 118800 tests --- modules/browser_object_panel_ui.py | 24 +++++++---- ..._tab_present_in_hamburger_history_menu.py} | 14 +++---- ...indow_present_in_hamburger_history_menu.py | 38 +++++++++++++++++ ...n_new_window_present_in_toolbar_history.py | 41 ------------------- ...bsite_present_in_hamburger_history_menu.py | 35 ++++++++++++++++ ...ened_website_present_in_toolbar_history.py | 38 ----------------- 6 files changed, 97 insertions(+), 93 deletions(-) rename tests/bookmarks_and_history/{test_opened_website_in_new_tab_present_in_toolbar_history.py => test_opened_website_in_new_tab_present_in_hamburger_history_menu.py} (64%) create mode 100644 tests/bookmarks_and_history/test_opened_website_in_new_window_present_in_hamburger_history_menu.py delete mode 100644 tests/bookmarks_and_history/test_opened_website_in_new_window_present_in_toolbar_history.py create mode 100644 tests/bookmarks_and_history/test_opened_website_present_in_hamburger_history_menu.py delete mode 100644 tests/bookmarks_and_history/test_opened_website_present_in_toolbar_history.py diff --git a/modules/browser_object_panel_ui.py b/modules/browser_object_panel_ui.py index efc9ed137..2804eed27 100644 --- a/modules/browser_object_panel_ui.py +++ b/modules/browser_object_panel_ui.py @@ -192,6 +192,20 @@ def get_all_history(self) -> List[WebElement]: history_items = self.get_elements("bookmark-item") return history_items + @BasePage.context_chrome + def verify_most_recent_history_item(self, expected_value: str) -> BasePage: + """ + Verify that the specified value is the most recent item in the history menu. + Argument: + Expected_value (str): The expected value of the most recent history entry + """ + + recent_history_items = self.get_elements("recent-history-content") + actual_value = recent_history_items[0].get_attribute("value") + assert actual_value == expected_value + + return self + @BasePage.context_chrome def get_random_history_entry(self) -> Optional[Tuple[str, str]]: """ @@ -217,13 +231,9 @@ def get_random_history_entry(self) -> Optional[Tuple[str, str]]: def _extract_url_from_history(self, raw_url: str) -> str: """ - Extract a valid HTTP(S) URL from a raw history image attribute. - - Firefox stores history URLs using special schemes like: - 'moz-anno:favicon:https://example.com' - This method locates the first occurrence of "http" and returns the substring from there. - - Args: + Extract a valid HTTP(S) URL from a raw history image attribute. This method locates the first occurrence of + "http" and returns the substring from there. + Argument: raw_url (str): The raw string value from the 'image' attribute of a history entry. """ if not raw_url: diff --git a/tests/bookmarks_and_history/test_opened_website_in_new_tab_present_in_toolbar_history.py b/tests/bookmarks_and_history/test_opened_website_in_new_tab_present_in_hamburger_history_menu.py similarity index 64% rename from tests/bookmarks_and_history/test_opened_website_in_new_tab_present_in_toolbar_history.py rename to tests/bookmarks_and_history/test_opened_website_in_new_tab_present_in_hamburger_history_menu.py index ffc294afe..90fe763f5 100644 --- a/tests/bookmarks_and_history/test_opened_website_in_new_tab_present_in_toolbar_history.py +++ b/tests/bookmarks_and_history/test_opened_website_in_new_tab_present_in_hamburger_history_menu.py @@ -2,7 +2,7 @@ from selenium.webdriver import Firefox from modules.browser_object import PanelUi, TabBar -from modules.page_object_generics import GenericPage +from modules.page_object import GenericPage @pytest.fixture() @@ -15,7 +15,7 @@ def use_profile(): return "theme_change" -ETSY_URL = "https://www.etsy.com/" +WIKIPEDIA_URL = "https://www.wikipedia.org/" def test_the_website_opened_in_new_tab_is_present_in_history_menu(driver: Firefox): @@ -25,14 +25,14 @@ def test_the_website_opened_in_new_tab_is_present_in_history_menu(driver: Firefo """ # Instantiate objects tabs = TabBar(driver) - page = GenericPage(driver, url=ETSY_URL) + page = GenericPage(driver, url=WIKIPEDIA_URL) panel = PanelUi(driver) - # Open a new tab, switch to it and verify is the url contains the desired domain + # Open a new tab, switch to it and verify is the url contains the desired page name tabs.open_web_page_in_new_tab(page, 2) - page.url_contains("etsy") + page.url_contains("wikipedia") - # Verify Etsy is present in the Hamburger Menu, History section and is on top of the list as the most recent + # Verify Wikipedia is present in the Hamburger Menu, History section and is on top of the list as the most recent # website visited panel.open_history_menu() - panel.expect_element_attribute_contains("recent-history-content", "value", "Etsy") + panel.verify_most_recent_history_item("Wikipedia") diff --git a/tests/bookmarks_and_history/test_opened_website_in_new_window_present_in_hamburger_history_menu.py b/tests/bookmarks_and_history/test_opened_website_in_new_window_present_in_hamburger_history_menu.py new file mode 100644 index 000000000..1194b62c2 --- /dev/null +++ b/tests/bookmarks_and_history/test_opened_website_in_new_window_present_in_hamburger_history_menu.py @@ -0,0 +1,38 @@ +import pytest +from selenium.webdriver import Firefox + +from modules.browser_object_panel_ui import PanelUi +from modules.page_object import GenericPage + + +@pytest.fixture() +def test_case(): + return "118805" + + +@pytest.fixture() +def use_profile(): + return "theme_change" + + +WIKIPEDIA_URL = "https://www.wikipedia.org/" + + +def test_the_website_opened_in_new_window_is_present_in_history_menu(driver: Firefox): + """ + C118805 - Verify that the website opened in new window is displayed in Hamburger Menu, History section, on top of the + list + """ + + # Instantiate objects + page = GenericPage(driver, url=WIKIPEDIA_URL) + panel = PanelUi(driver) + + # Open a new window, switch to it and verify is the url contains the desired page name + panel.open_and_switch_to_new_window("window") + page.open() + page.url_contains("wikipedia") + + # Verify Wikipedia is present in the history menu and is on top of the list as the most recent website visited + panel.open_history_menu() + panel.verify_most_recent_history_item("Wikipedia") diff --git a/tests/bookmarks_and_history/test_opened_website_in_new_window_present_in_toolbar_history.py b/tests/bookmarks_and_history/test_opened_website_in_new_window_present_in_toolbar_history.py deleted file mode 100644 index 76a3f2370..000000000 --- a/tests/bookmarks_and_history/test_opened_website_in_new_window_present_in_toolbar_history.py +++ /dev/null @@ -1,41 +0,0 @@ -import pytest -from selenium.webdriver import Firefox - -from modules.browser_object_panel_ui import PanelUi -from modules.page_object_generics import GenericPage - - -@pytest.fixture() -def test_case(): - return "118805" - - -FACEBOOK_URL = "https://www.facebook.com/" -AMAZON_URL = "https://www.amazon.com/" -YOUTUBE_URL = "https://www.youtube.com/" - -WEBSITES = [FACEBOOK_URL, AMAZON_URL] - - -def test_the_website_opened_in_new_window_is_present_in_history_menu(driver: Firefox): - """ - C118805 - Verify that the website opened in new window is displayed in the Toolbar History submenu on top of the - list - """ - - for url in WEBSITES: - GenericPage(driver, url=url).open() - - panel_ui = PanelUi(driver) - panel_ui.open_and_switch_to_new_window("window") - - page = GenericPage(driver, url=YOUTUBE_URL) - page.open() - page.url_contains("youtube") - - panel_ui.open_history_menu() - - # Verify YouTube is present in the history menu and is on top of the list as the most recent website visited - panel_ui.expect_element_attribute_contains( - "recent-history-content", "value", "YouTube" - ) diff --git a/tests/bookmarks_and_history/test_opened_website_present_in_hamburger_history_menu.py b/tests/bookmarks_and_history/test_opened_website_present_in_hamburger_history_menu.py new file mode 100644 index 000000000..856db7f50 --- /dev/null +++ b/tests/bookmarks_and_history/test_opened_website_present_in_hamburger_history_menu.py @@ -0,0 +1,35 @@ +import pytest +from selenium.webdriver import Firefox + +from modules.browser_object_panel_ui import PanelUi +from modules.page_object import GenericPage + + +@pytest.fixture() +def test_case(): + return "118800" + + +@pytest.fixture() +def use_profile(): + return "theme_change" + + +WIKIPEDIA_URL = "https://www.wikipedia.org/" + + +def test_the_most_recent_website_is_present_in_history_menu(driver: Firefox): + """ + C118800 - Verify that the most recently opened website is displayed in Hamburger Menu, History section, on top of the + list + """ + # Instantiate objects + page = GenericPage(driver, url=WIKIPEDIA_URL) + panel = PanelUi(driver) + + # Open the desired webpage + page.open() + + # Verify Wikipedia is present in the history menu and is on top of the list as the most recent website visited + panel.open_history_menu() + panel.verify_most_recent_history_item("Wikipedia") diff --git a/tests/bookmarks_and_history/test_opened_website_present_in_toolbar_history.py b/tests/bookmarks_and_history/test_opened_website_present_in_toolbar_history.py deleted file mode 100644 index feaa2eff4..000000000 --- a/tests/bookmarks_and_history/test_opened_website_present_in_toolbar_history.py +++ /dev/null @@ -1,38 +0,0 @@ -import pytest -from selenium.webdriver import Firefox - -from modules.browser_object_panel_ui import PanelUi -from modules.page_object_generics import GenericPage - - -@pytest.fixture() -def test_case(): - return "118800" - - -FACEBOOK_URL = "https://www.facebook.com/" -AMAZON_URL = "https://www.amazon.com/" -YOUTUBE_URL = "https://www.youtube.com/" - -WEBSITES = [FACEBOOK_URL, AMAZON_URL, YOUTUBE_URL] - - -def test_the_most_recent_website_is_present_in_history_menu(driver: Firefox): - """ - C118800 - Verify that the most recently opened website is displayed in the Toolbar History submenu on top of the - list - """ - - for url in WEBSITES: - GenericPage(driver, url=url).open() - - panel_ui = PanelUi(driver) - panel_ui.open() - panel_ui.open_history_menu() - - # Verify YouTube is present in the history menu and is on top of the list as the most recent website visited - with driver.context(driver.CONTEXT_CHROME): - recent_history_elements = panel_ui.get_elements("recent-history-content") - assert recent_history_elements[0].get_attribute("value") == "YouTube", ( - "YouTube is not the first item in the recent history." - ) From 287371aa188c7f53c0efc613ff4ebbe71ae87ee8 Mon Sep 17 00:00:00 2001 From: soncuteanca Date: Wed, 17 Sep 2025 19:09:22 +0300 Subject: [PATCH 10/11] Some retouch, improve comments, and visibility --- modules/browser_object_panel_ui.py | 68 ++++++++++--------- .../test_clear_all_history.py | 4 +- .../test_clear_recent_history_displayed.py | 1 - .../test_open_websites_from_history.py | 11 +-- ...w_tab_present_in_hamburger_history_menu.py | 6 +- ...indow_present_in_hamburger_history_menu.py | 6 +- ...bsite_present_in_hamburger_history_menu.py | 3 +- 7 files changed, 51 insertions(+), 48 deletions(-) diff --git a/modules/browser_object_panel_ui.py b/modules/browser_object_panel_ui.py index 2804eed27..711509fb9 100644 --- a/modules/browser_object_panel_ui.py +++ b/modules/browser_object_panel_ui.py @@ -155,6 +155,31 @@ def open_private_window(self) -> BasePage: self.get_element("panel-ui-new-private-window").click() return self + @BasePage.context_chrome + def redirect_to_about_logins_page(self) -> BasePage: + """ + Opens the about:logins page by clicking the Password option in Hamburger Menu" + """ + self.open_panel_menu() + self.get_element("password-button").click() + return self + + @BasePage.context_chrome + def reopen_recently_closed_tabs(self) -> BasePage: + """Reopen all recently closed tabs""" + self.open_panel_menu() + self.click_on("panel-ui-history") + + self.click_on("panel-ui-history-recently-closed") + if self.sys_platform() == "Linux": + sleep(2) + + self.click_on("panel-ui-history-recently-closed-reopen-tabs") + + return self + + # History + @BasePage.context_chrome def open_history_menu(self) -> BasePage: """ @@ -166,9 +191,12 @@ def open_history_menu(self) -> BasePage: @BasePage.context_chrome def open_clear_history_dialog(self) -> BasePage: - """Opens the clear history dialog and switches to iframe context, assuming the history panel is opened""" + """ + Opens the clear history dialog and switches to iframe context, assuming the history panel is opened + """ self.click_on("clear-recent-history") + # Switch to iframe self.element_visible("iframe") iframe = self.get_element("iframe") BrowserActions(self.driver).switch_to_iframe_context(iframe) @@ -199,11 +227,9 @@ def verify_most_recent_history_item(self, expected_value: str) -> BasePage: Argument: Expected_value (str): The expected value of the most recent history entry """ - recent_history_items = self.get_elements("recent-history-content") actual_value = recent_history_items[0].get_attribute("value") assert actual_value == expected_value - return self @BasePage.context_chrome @@ -226,7 +252,6 @@ def get_random_history_entry(self) -> Optional[Tuple[str, str]]: trimmed_url = self._extract_url_from_history(raw_url) assert trimmed_url and label, "History item has missing URL or label." - return trimmed_url, label def _extract_url_from_history(self, raw_url: str) -> str: @@ -238,20 +263,19 @@ def _extract_url_from_history(self, raw_url: str) -> str: """ if not raw_url: return "" - if "http" in raw_url: return raw_url[raw_url.find("http") :] - return raw_url.strip() @BasePage.context_chrome - def redirect_to_about_logins_page(self) -> BasePage: + def confirm_history_clear(self): """ - Opens the about:logins page by clicking the Password option in Hamburger Menu" + Confirm that the history is empty """ - self.open_panel_menu() - self.get_element("password-button").click() - return self + self.open_history_menu() + self.expect_element_attribute_contains( + "recent-history-content", "value", "(Empty)" + ) # Bookmarks section @@ -327,25 +351,3 @@ def get_bookmark_tags(self, tags: List[str]) -> List[str]: ) for tag in tags ] - - @BasePage.context_chrome - def confirm_history_clear(self): - """Confirm that the history is empty""" - self.open_history_menu() - self.expect_element_attribute_contains( - "recent-history-content", "value", "(Empty)" - ) - - @BasePage.context_chrome - def reopen_recently_closed_tabs(self) -> BasePage: - """Reopen all recently closed tabs""" - self.open_panel_menu() - self.click_on("panel-ui-history") - - self.click_on("panel-ui-history-recently-closed") - if self.sys_platform() == "Linux": - sleep(2) - - self.click_on("panel-ui-history-recently-closed-reopen-tabs") - - return self diff --git a/tests/bookmarks_and_history/test_clear_all_history.py b/tests/bookmarks_and_history/test_clear_all_history.py index 795876ba6..464b57a99 100644 --- a/tests/bookmarks_and_history/test_clear_all_history.py +++ b/tests/bookmarks_and_history/test_clear_all_history.py @@ -19,7 +19,6 @@ def test_clear_all_history(driver: Firefox): """ C172045: Verify that the user can Clear all the History """ - # Instantiate objects page = GenericPage(driver) panel = PanelUi(driver) @@ -30,7 +29,8 @@ def test_clear_all_history(driver: Firefox): # Select the option to clear all the history panel.select_history_time_range_option("Everything") - # A method in panel-ui with selectors moved accordingly would work better, I'll come to this later, couldn't make it work so far + # A method in panel BOM with selectors moved accordingly would make more sense, I'll come to this later, + # there are some context switching + iframe entanglements, couldn't make it work so far page.click_on("clear-history-button") # Verify all the history is deleted diff --git a/tests/bookmarks_and_history/test_clear_recent_history_displayed.py b/tests/bookmarks_and_history/test_clear_recent_history_displayed.py index 2cec4ea3c..cd370613b 100644 --- a/tests/bookmarks_and_history/test_clear_recent_history_displayed.py +++ b/tests/bookmarks_and_history/test_clear_recent_history_displayed.py @@ -13,7 +13,6 @@ def test_clear_recent_history_displayed(driver: Firefox): """ C172043: Clear recent history panel displayed """ - # Instantiate object panel = PanelUi(driver) diff --git a/tests/bookmarks_and_history/test_open_websites_from_history.py b/tests/bookmarks_and_history/test_open_websites_from_history.py index a3f51bea2..d118a2ea1 100644 --- a/tests/bookmarks_and_history/test_open_websites_from_history.py +++ b/tests/bookmarks_and_history/test_open_websites_from_history.py @@ -21,21 +21,22 @@ def test_open_websites_from_history(driver: Firefox): """ C118807: Verify that the user can open any random website from Hamburger Menu, History section """ - - # Instantiate objects + # Instantiate object panel = PanelUi(driver) - panel.open_history_menu() + # Open History section from Hamburger Menu and get a random entry from browser history + panel.open_history_menu() result = panel.get_random_history_entry() + # Skip test if no history entries are available if result is None: logging.info("Test skipped: No history available") return - # Retrieve a random item from history and its label + # Extract URL and page title from the selected history entry url, label = result - # Open the corresponding page and verify URL and title match + # Navigate to the selected page and verify it loads correctly page = GenericPage(driver, url=url) page.open() page.url_contains(url) diff --git a/tests/bookmarks_and_history/test_opened_website_in_new_tab_present_in_hamburger_history_menu.py b/tests/bookmarks_and_history/test_opened_website_in_new_tab_present_in_hamburger_history_menu.py index 90fe763f5..abe3fe8ba 100644 --- a/tests/bookmarks_and_history/test_opened_website_in_new_tab_present_in_hamburger_history_menu.py +++ b/tests/bookmarks_and_history/test_opened_website_in_new_tab_present_in_hamburger_history_menu.py @@ -28,11 +28,11 @@ def test_the_website_opened_in_new_tab_is_present_in_history_menu(driver: Firefo page = GenericPage(driver, url=WIKIPEDIA_URL) panel = PanelUi(driver) - # Open a new tab, switch to it and verify is the url contains the desired page name + # Open a desired webpage in a new tab tabs.open_web_page_in_new_tab(page, 2) page.url_contains("wikipedia") - # Verify Wikipedia is present in the Hamburger Menu, History section and is on top of the list as the most recent - # website visited + # Verify the opened webpage from last step is present in the Hamburger Menu, History section and is on top of the + # list as the most recent website visited panel.open_history_menu() panel.verify_most_recent_history_item("Wikipedia") diff --git a/tests/bookmarks_and_history/test_opened_website_in_new_window_present_in_hamburger_history_menu.py b/tests/bookmarks_and_history/test_opened_website_in_new_window_present_in_hamburger_history_menu.py index 1194b62c2..c1139f16c 100644 --- a/tests/bookmarks_and_history/test_opened_website_in_new_window_present_in_hamburger_history_menu.py +++ b/tests/bookmarks_and_history/test_opened_website_in_new_window_present_in_hamburger_history_menu.py @@ -23,16 +23,16 @@ def test_the_website_opened_in_new_window_is_present_in_history_menu(driver: Fir C118805 - Verify that the website opened in new window is displayed in Hamburger Menu, History section, on top of the list """ - # Instantiate objects page = GenericPage(driver, url=WIKIPEDIA_URL) panel = PanelUi(driver) - # Open a new window, switch to it and verify is the url contains the desired page name + # Open a desired webpage in a new window panel.open_and_switch_to_new_window("window") page.open() page.url_contains("wikipedia") - # Verify Wikipedia is present in the history menu and is on top of the list as the most recent website visited + # Verify the opened webpage from last step is present in the Hamburger Menu, History section and is on top of the + # list as the most recent website visited panel.open_history_menu() panel.verify_most_recent_history_item("Wikipedia") diff --git a/tests/bookmarks_and_history/test_opened_website_present_in_hamburger_history_menu.py b/tests/bookmarks_and_history/test_opened_website_present_in_hamburger_history_menu.py index 856db7f50..bd75c0d41 100644 --- a/tests/bookmarks_and_history/test_opened_website_present_in_hamburger_history_menu.py +++ b/tests/bookmarks_and_history/test_opened_website_present_in_hamburger_history_menu.py @@ -30,6 +30,7 @@ def test_the_most_recent_website_is_present_in_history_menu(driver: Firefox): # Open the desired webpage page.open() - # Verify Wikipedia is present in the history menu and is on top of the list as the most recent website visited + # Verify the opened webpage from last step is present in the Hamburger Menu, History section and is on top of the + # list as the most recent website visited panel.open_history_menu() panel.verify_most_recent_history_item("Wikipedia") From 31110308ff33e795d2a86915aa5660c4d8cd746b Mon Sep 17 00:00:00 2001 From: soncuteanca Date: Thu, 18 Sep 2025 17:07:21 +0300 Subject: [PATCH 11/11] Add test 118806 --- ...t_private_window_website_not_in_history.py | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/tests/bookmarks_and_history/test_private_window_website_not_in_history.py b/tests/bookmarks_and_history/test_private_window_website_not_in_history.py index 88f5bc1a3..ddf8d4b03 100644 --- a/tests/bookmarks_and_history/test_private_window_website_not_in_history.py +++ b/tests/bookmarks_and_history/test_private_window_website_not_in_history.py @@ -15,20 +15,16 @@ def test_case(): def test_opened_website_in_private_window_not_captured_in_history_list(driver: Firefox): """ - C118806 - Verify that opened websites in a New Private Window will not be displayed in the Hamburger submenu history + C118806 - Verify that opened websites in a New Private Window will not be displayed in the Hamburger History submenu """ + # Instantiate objects + panel = PanelUi(driver) + page = GenericPage(driver, url=YOUTUBE_URL) - panel_ui = PanelUi(driver) - panel_ui.open_and_switch_to_new_window("private") + # Open the desired webpage in a new Private window + panel.open_and_switch_to_new_window("private") + page.open() - GenericPage(driver, url=YOUTUBE_URL).open() - - panel_ui.open_history_menu() - - with driver.context(driver.CONTEXT_CHROME): - empty_label = panel_ui.get_element("recent-history-content").get_attribute( - "value" - ) - assert empty_label == "(Empty)", ( - f"Expected history to be empty, but found '{empty_label}'" - ) + # Verify that the webpage opened in Private window is not listed in History + panel.open_history_menu() + panel.confirm_history_clear()