Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions modules/browser_object_forget_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,33 @@

class ForgetPanel(BasePage):
"""
BOM for the forget panel
BOM for the Forget Panel
"""

URL_TEMPLATE = ""

def select_timeframe(
self,
timeframe: Literal["forget-five-minutes", "forget-two-hours", "forget-one-day"],
) -> "ForgetPanel":
"""
Select a specific timeframe option in the forget panel.
This will click the option regardless of what's currently selected.

Argument:
timeframe: Timeframe to forget. Restricted options to "forget-five-minutes",
"forget-two-hours", or "forget-one-day"
"""
self.click_on(timeframe)
return self

def forget_history(
self,
timeframe: Literal["forget-five-minutes", "forget-two-hours", "forget-one-day"],
) -> BasePage:
with self.driver.context(self.driver.CONTEXT_CHROME):
self.get_element(timeframe).click()
self.get_element("forget-confirm-button").click()
return self
) -> "ForgetPanel":
"""
Forget browsing history for a given timeframe.
"""
self.select_timeframe(timeframe)
self.click_on("forget-confirm-button")
return self
6 changes: 6 additions & 0 deletions modules/browser_object_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,12 @@ def select_element_in_nav(self, element: str) -> BasePage:
self.get_element(element).click()
return self

@BasePage.context_chrome
def open_forget_panel(self) -> BasePage:
"""Open the Forget Panel by clicking the Forget button in the toolbar."""
self.get_element("forget-button").click()
return self

@BasePage.context_chrome
def get_legacy_search_engine_label(self) -> str:
"""Return the displayed engine name from the legacy search bar."""
Expand Down
25 changes: 23 additions & 2 deletions modules/browser_object_tabbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,33 @@ def close_tab(self, tab: WebElement) -> BasePage:
self.get_element("tab-x-icon", parent_element=tab).click()
return self

def open_web_page_in_new_tab(self, web_page: BasePage, num_tabs: int) -> BasePage:
def open_single_page_in_new_tab(self, page: BasePage, num_tabs: int) -> BasePage:
"""
Opens a new tab, switches the driver context to the new tab, and opens the given webpage
Arguments:
page: The page object to open in the new tab
num_tabs: Expected total number of tabs after opening the new tab (used for waiting)
"""
self.new_tab_by_button()
self.wait_for_num_tabs(num_tabs)
self.driver.switch_to.window(self.driver.window_handles[-1])
web_page.open()
page.open()
return self

def open_multiple_tabs_with_pages(self, pages: list) -> "TabBar":
"""
Opens multiple new tabs and navigates to different pages in each tab.

Argument:
pages: List of page objects or URLs to open in separate tabs
"""
for page in pages:
self.new_tab_by_button()
self.wait_for_num_tabs(len(self.driver.window_handles))
self.driver.switch_to.window(self.driver.window_handles[-1])

if isinstance(page, str):
self.driver.get(page)
else:
page.open()
return self
16 changes: 8 additions & 8 deletions tests/bookmarks_and_history/test_deleted_page_not_remembered.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ def test_deleted_page_not_remembered(driver: Firefox, sys_platform):
"""
C216273: Verify that the deleted page from the Hamburger History submenu is not remembered or autofilled in the URL bar
"""
panel_ui = PanelUi(driver)
panel_ui.open()
# Instantiate objects
panel = PanelUi(driver)
nav = Navigation(driver)
context_menu = ContextMenu(driver)

panel_ui.open_history_menu()
panel_ui.context_click("bookmark-by-title", labels=["Firefox Privacy Notice"])

# Open history menu and right-click on a specific history entry and delete it
panel.open_history_menu()
panel.context_click("bookmark-by-title", labels=["Firefox Privacy Notice"])
context_menu.click_and_hide_menu("context-menu-delete-page")
nav.type_in_awesome_bar("Firefox Privacy Notice")

with driver.context(driver.CONTEXT_CHROME):
nav.expect(lambda _: len(nav.get_elements("results-dropdown")) == 1)
# Type the deleted page name in the URL bar and verify the deleted page is not suggested
nav.type_in_awesome_bar("Firefox Privacy Notice")
nav.expect(lambda _: len(nav.get_elements("results-dropdown")) == 1)
110 changes: 56 additions & 54 deletions tests/bookmarks_and_history/test_history_menu_from_different_places.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from modules.browser_object_navigation import Navigation
from modules.browser_object_panel_ui import PanelUi
from modules.browser_object_tabbar import TabBar
from modules.page_base import BasePage
from modules.page_object_customize_firefox import CustomizeFirefox


Expand All @@ -15,11 +16,15 @@ def test_case():
return "118799"


# Single-use helper kept in test file (YAGNI). Avoids duplication and/or overengineering
@BasePage.context_chrome
def assert_elements_visibility(ui_object, elements: dict, source: str):
"""Helper function to assert visibility of elements in a given UI source."""
"""
Helper function to assert visibility of elements in a given UI source.
"""
for name, locator in elements.items():
element = ui_object.get_element(locator)
assert element.is_displayed(), f"{name} should be visible in {source}"
assert element.is_displayed()


def test_history_menu_in_different_places(driver: Firefox):
Expand All @@ -28,77 +33,74 @@ def test_history_menu_in_different_places(driver: Firefox):
Toolbar)
"""

# 1. History options from Hamburger Menu
panel_ui = PanelUi(driver)
panel_ui.open_history_menu()

with driver.context(driver.CONTEXT_CHROME):
hamburger_menu_elements = {
"Back Button": "history-back-button",
"History Title": "history_title",
"Recently Closed Tabs": "panel-ui-history-recently-closed",
"Recently Closed Windows": "recently_closed_windows",
"Search History": "search_history",
"Clear Recent History": "clear-recent-history",
"Recent History": "recent_history",
"Manage History": "manage_history",
}
assert_elements_visibility(panel_ui, hamburger_menu_elements, "Hamburger Menu")

# 2. History options from Menu Bar
# 1. Verify History options from Hamburger Menu
panel = PanelUi(driver)
panel.open_history_menu()

hamburger_menu_elements = {
"Back Button": "history-back-button",
"History Title": "history_title",
"Recently Closed Tabs": "panel-ui-history-recently-closed",
"Recently Closed Windows": "recently_closed_windows",
"Search History": "search_history",
"Clear Recent History": "clear-recent-history",
"Recent History": "recent_history",
"Manage History": "manage_history",
}
assert_elements_visibility(panel, hamburger_menu_elements, "Hamburger Menu")

# 2. Verify History options from Menu Bar
menu_bar = MenuBar(driver)

if platform.system() != "Darwin":
menu_bar.open_menu("History")

with driver.context(driver.CONTEXT_CHROME):
menu_bar_elements = {
"Show All History": "menu-bar-show-all-history",
"Clear Recent History": "menu-bar-clear-recent-history",
"Restore Previous Session": "menu-bar-restore-previous-session",
"Search History": "menu-bar-search-history",
"Recently Closed Tabs": "menu-bar-recently-closed-tabs",
"Recently Closed Windows": "menu-bar-recently-closed-windows",
}
assert_elements_visibility(menu_bar, menu_bar_elements, "Menu Bar")
menu_bar_elements = {
"Show All History": "menu-bar-show-all-history",
"Clear Recent History": "menu-bar-clear-recent-history",
"Restore Previous Session": "menu-bar-restore-previous-session",
"Search History": "menu-bar-search-history",
"Recently Closed Tabs": "menu-bar-recently-closed-tabs",
"Recently Closed Windows": "menu-bar-recently-closed-windows",
}
assert_elements_visibility(menu_bar, menu_bar_elements, "Menu Bar")
else:
print("Skipping Menu Bar verification on macOS")

# 3. History options from Toolbar (History and Library)
# 3. Verify History options from Toolbar (History and Library)
customize_firefox = CustomizeFirefox(driver)
tabs = TabBar(driver)
nav = Navigation(driver)

panel_ui.navigate_to_customize_toolbar()
panel.navigate_to_customize_toolbar()
customize_firefox.add_widget_to_toolbar("history")

tabs.new_tab_by_button()
tabs.switch_to_new_tab()

with driver.context(driver.CONTEXT_CHROME):
nav.click_on("history-button")
nav.click_on("history-button")

history_toolbar_elements = {
"Recently Closed Tabs": "toolbar-history-recently-closed-tabs",
"Recently Closed Windows": "toolbar-history-recently-closed-windows",
"Search History": "toolbar-history-search-history",
"Clear Recent History": "toolbar-history-clear-recent-history",
"Recent History": "toolbar-history-recent_history",
"Manage History": "toolbar-history-manage_history",
}
assert_elements_visibility(nav, history_toolbar_elements, "Toolbar History")
history_toolbar_elements = {
"Recently Closed Tabs": "toolbar-history-recently-closed-tabs",
"Recently Closed Windows": "toolbar-history-recently-closed-windows",
"Search History": "toolbar-history-search-history",
"Clear Recent History": "toolbar-history-clear-recent-history",
"Recent History": "toolbar-history-recent_history",
"Manage History": "toolbar-history-manage_history",
}
assert_elements_visibility(nav, history_toolbar_elements, "Toolbar History")

panel_ui.open_panel_menu()
panel_ui.navigate_to_customize_toolbar()
customize_firefox.add_widget_to_toolbar("library")
panel.open_panel_menu()
panel.navigate_to_customize_toolbar()
customize_firefox.add_widget_to_toolbar("library")

tabs.new_tab_by_button()
tabs.switch_to_new_tab()
tabs.new_tab_by_button()
tabs.switch_to_new_tab()

nav.click_on("library-button")
nav.click_on("library-history-submenu-button")
nav.click_on("library-button")
nav.click_on("library-history-submenu-button")

library_toolbar_elements = (
history_toolbar_elements # Reuse the same locators from a different path
)
assert_elements_visibility(nav, library_toolbar_elements, "Toolbar Library")
library_toolbar_elements = (
history_toolbar_elements # Reuse the same locators from a different path
)
assert_elements_visibility(nav, library_toolbar_elements, "Toolbar Library")
2 changes: 1 addition & 1 deletion tests/bookmarks_and_history/test_import_bookmarks_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest
from selenium.webdriver import Firefox

from modules.browser_object_navigation import Navigation
from modules.browser_object import Navigation
from modules.page_object import AboutPrefs

NEWS_ARTICLE_TITLE = "Level 1, 2 evacuations issued for fire burning in Chelan"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_the_website_opened_in_new_tab_is_present_in_history_menu(driver: Firefo
panel = PanelUi(driver)

# Open a desired webpage in a new tab
tabs.open_web_page_in_new_tab(page, 2)
tabs.open_single_page_in_new_tab(page, 2)
page.url_contains("wikipedia")

# Verify the opened webpage from last step is present in the Hamburger Menu, History section and is on top of the
Expand Down
38 changes: 13 additions & 25 deletions tests/bookmarks_and_history/test_user_can_forget_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
from selenium.webdriver import Firefox

from modules.browser_object import ForgetPanel, Navigation, PanelUi, TabBar
from modules.page_object import CustomizeFirefox, GenericPage
from modules.page_object import CustomizeFirefox


@pytest.fixture()
def test_case():
return "174072"


links = [
ABOUT_PAGES = [
"about:about",
"about:addons",
"about:cache",
Expand All @@ -22,37 +22,25 @@ def test_user_can_forget_history(driver: Firefox):
"""
C174072: Verify that the user can Forget all the history from the last 5 minutes
"""
# Instantiate objects
tabs = TabBar(driver)
panel_ui = PanelUi(driver)
panel = PanelUi(driver)
nav = Navigation(driver)
forget_panel = ForgetPanel(driver)
gen_page = GenericPage(driver, url="https://www.google.com/")
customize_firefox = CustomizeFirefox(driver)

tabs_to_open = 4

for i in range(tabs_to_open):
driver.get(links[i])
tabs.new_tab_by_button()
tabs.switch_to_new_tab()

panel_ui.open_panel_menu()
panel_ui.navigate_to_customize_toolbar()
# Add the Forget button to the toolbar
panel.open_panel_menu()
panel.navigate_to_customize_toolbar()
customize_firefox.add_widget_to_toolbar("forget")

tabs.new_tab_by_button()
tabs.switch_to_new_tab()

gen_page.open()

with driver.context(driver.CONTEXT_CHROME):
nav.get_element("forget-button").click()
assert (
forget_panel.get_element("forget-five-minutes").get_attribute("selected")
== "true"
)
# Create history
tabs.open_multiple_tabs_with_pages(ABOUT_PAGES)

# Use Forget button to clear the last 5 minutes of history
nav.open_forget_panel()
forget_panel.forget_history("forget-five-minutes")

# Verify history was removed
tabs.switch_to_new_tab()
panel_ui.element_does_not_exist("bookmark-item")
panel.element_does_not_exist("bookmark-item")
Loading