7
7
from modules .browser_object_navigation import Navigation
8
8
from modules .browser_object_panel_ui import PanelUi
9
9
from modules .browser_object_tabbar import TabBar
10
+ from modules .page_base import BasePage
10
11
from modules .page_object_customize_firefox import CustomizeFirefox
11
12
12
13
@@ -15,11 +16,15 @@ def test_case():
15
16
return "118799"
16
17
17
18
19
+ # Single-use helper kept in test file (YAGNI). Avoids duplication and/or overengineering
20
+ @BasePage .context_chrome
18
21
def assert_elements_visibility (ui_object , elements : dict , source : str ):
19
- """Helper function to assert visibility of elements in a given UI source."""
22
+ """
23
+ Helper function to assert visibility of elements in a given UI source.
24
+ """
20
25
for name , locator in elements .items ():
21
26
element = ui_object .get_element (locator )
22
- assert element .is_displayed (), f" { name } should be visible in { source } "
27
+ assert element .is_displayed ()
23
28
24
29
25
30
def test_history_menu_in_different_places (driver : Firefox ):
@@ -28,77 +33,74 @@ def test_history_menu_in_different_places(driver: Firefox):
28
33
Toolbar)
29
34
"""
30
35
31
- # 1. History options from Hamburger Menu
32
- panel_ui = PanelUi (driver )
33
- panel_ui .open_history_menu ()
34
-
35
- with driver .context (driver .CONTEXT_CHROME ):
36
- hamburger_menu_elements = {
37
- "Back Button" : "history-back-button" ,
38
- "History Title" : "history_title" ,
39
- "Recently Closed Tabs" : "panel-ui-history-recently-closed" ,
40
- "Recently Closed Windows" : "recently_closed_windows" ,
41
- "Search History" : "search_history" ,
42
- "Clear Recent History" : "clear-recent-history" ,
43
- "Recent History" : "recent_history" ,
44
- "Manage History" : "manage_history" ,
45
- }
46
- assert_elements_visibility (panel_ui , hamburger_menu_elements , "Hamburger Menu" )
47
-
48
- # 2. History options from Menu Bar
36
+ # 1. Verify History options from Hamburger Menu
37
+ panel = PanelUi (driver )
38
+ panel .open_history_menu ()
39
+
40
+ hamburger_menu_elements = {
41
+ "Back Button" : "history-back-button" ,
42
+ "History Title" : "history_title" ,
43
+ "Recently Closed Tabs" : "panel-ui-history-recently-closed" ,
44
+ "Recently Closed Windows" : "recently_closed_windows" ,
45
+ "Search History" : "search_history" ,
46
+ "Clear Recent History" : "clear-recent-history" ,
47
+ "Recent History" : "recent_history" ,
48
+ "Manage History" : "manage_history" ,
49
+ }
50
+ assert_elements_visibility (panel , hamburger_menu_elements , "Hamburger Menu" )
51
+
52
+ # 2. Verify History options from Menu Bar
49
53
menu_bar = MenuBar (driver )
50
54
51
55
if platform .system () != "Darwin" :
52
56
menu_bar .open_menu ("History" )
53
57
54
- with driver .context (driver .CONTEXT_CHROME ):
55
- menu_bar_elements = {
56
- "Show All History" : "menu-bar-show-all-history" ,
57
- "Clear Recent History" : "menu-bar-clear-recent-history" ,
58
- "Restore Previous Session" : "menu-bar-restore-previous-session" ,
59
- "Search History" : "menu-bar-search-history" ,
60
- "Recently Closed Tabs" : "menu-bar-recently-closed-tabs" ,
61
- "Recently Closed Windows" : "menu-bar-recently-closed-windows" ,
62
- }
63
- assert_elements_visibility (menu_bar , menu_bar_elements , "Menu Bar" )
58
+ menu_bar_elements = {
59
+ "Show All History" : "menu-bar-show-all-history" ,
60
+ "Clear Recent History" : "menu-bar-clear-recent-history" ,
61
+ "Restore Previous Session" : "menu-bar-restore-previous-session" ,
62
+ "Search History" : "menu-bar-search-history" ,
63
+ "Recently Closed Tabs" : "menu-bar-recently-closed-tabs" ,
64
+ "Recently Closed Windows" : "menu-bar-recently-closed-windows" ,
65
+ }
66
+ assert_elements_visibility (menu_bar , menu_bar_elements , "Menu Bar" )
64
67
else :
65
68
print ("Skipping Menu Bar verification on macOS" )
66
69
67
- # 3. History options from Toolbar (History and Library)
70
+ # 3. Verify History options from Toolbar (History and Library)
68
71
customize_firefox = CustomizeFirefox (driver )
69
72
tabs = TabBar (driver )
70
73
nav = Navigation (driver )
71
74
72
- panel_ui .navigate_to_customize_toolbar ()
75
+ panel .navigate_to_customize_toolbar ()
73
76
customize_firefox .add_widget_to_toolbar ("history" )
74
77
75
78
tabs .new_tab_by_button ()
76
79
tabs .switch_to_new_tab ()
77
80
78
- with driver .context (driver .CONTEXT_CHROME ):
79
- nav .click_on ("history-button" )
81
+ nav .click_on ("history-button" )
80
82
81
- history_toolbar_elements = {
82
- "Recently Closed Tabs" : "toolbar-history-recently-closed-tabs" ,
83
- "Recently Closed Windows" : "toolbar-history-recently-closed-windows" ,
84
- "Search History" : "toolbar-history-search-history" ,
85
- "Clear Recent History" : "toolbar-history-clear-recent-history" ,
86
- "Recent History" : "toolbar-history-recent_history" ,
87
- "Manage History" : "toolbar-history-manage_history" ,
88
- }
89
- assert_elements_visibility (nav , history_toolbar_elements , "Toolbar History" )
83
+ history_toolbar_elements = {
84
+ "Recently Closed Tabs" : "toolbar-history-recently-closed-tabs" ,
85
+ "Recently Closed Windows" : "toolbar-history-recently-closed-windows" ,
86
+ "Search History" : "toolbar-history-search-history" ,
87
+ "Clear Recent History" : "toolbar-history-clear-recent-history" ,
88
+ "Recent History" : "toolbar-history-recent_history" ,
89
+ "Manage History" : "toolbar-history-manage_history" ,
90
+ }
91
+ assert_elements_visibility (nav , history_toolbar_elements , "Toolbar History" )
90
92
91
- panel_ui .open_panel_menu ()
92
- panel_ui .navigate_to_customize_toolbar ()
93
- customize_firefox .add_widget_to_toolbar ("library" )
93
+ panel .open_panel_menu ()
94
+ panel .navigate_to_customize_toolbar ()
95
+ customize_firefox .add_widget_to_toolbar ("library" )
94
96
95
- tabs .new_tab_by_button ()
96
- tabs .switch_to_new_tab ()
97
+ tabs .new_tab_by_button ()
98
+ tabs .switch_to_new_tab ()
97
99
98
- nav .click_on ("library-button" )
99
- nav .click_on ("library-history-submenu-button" )
100
+ nav .click_on ("library-button" )
101
+ nav .click_on ("library-history-submenu-button" )
100
102
101
- library_toolbar_elements = (
102
- history_toolbar_elements # Reuse the same locators from a different path
103
- )
104
- assert_elements_visibility (nav , library_toolbar_elements , "Toolbar Library" )
103
+ library_toolbar_elements = (
104
+ history_toolbar_elements # Reuse the same locators from a different path
105
+ )
106
+ assert_elements_visibility (nav , library_toolbar_elements , "Toolbar Library" )
0 commit comments