Skip to content

Commit b4bc81b

Browse files
Hani YacoubHani Yacoub
authored andcommitted
Refactor 1
1 parent c56fdd2 commit b4bc81b

7 files changed

+36
-28
lines changed

modules/browser_object_tabbar.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def get_tab_title(self, tab_element: WebElement) -> str:
136136
tab_label = tab_element.find_element(*self.get_selector("tab-title"))
137137
return tab_label.text
138138

139+
@BasePage.context_chrome
139140
def expect_tab_sound_status(
140141
self, identifier: Union[str, int], status: MediaStatus
141142
) -> BasePage:

tests/tabs/test_active_tab.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from modules.browser_object import TabBar
55

66

7+
NUM_TABS = 5
8+
79
@pytest.fixture()
810
def test_case():
911
return "134646"
@@ -14,15 +16,16 @@ def test_active_tab(driver: Firefox):
1416
"""
1517
C134646, ensures that the selected tab is highlighted
1618
"""
19+
20+
# Instantiate objects
1721
tabs = TabBar(driver)
18-
num_tabs = 5
1922

2023
# Open 5 tabs
21-
for i in range(num_tabs):
24+
for i in range(NUM_TABS):
2225
tabs.new_tab_by_button()
2326

2427
# Go through all the tabs and ensure the focus is correct
25-
for i in range(1, num_tabs + 2):
28+
for i in range(1, NUM_TABS + 2):
2629
with driver.context(driver.CONTEXT_CHROME):
2730
target_tab = tabs.get_tab(i)
2831
target_tab.click()

tests/tabs/test_close_pinned_tab_via_mouse.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,25 @@ def test_close_pinned_tab_via_middle_click(driver: Firefox):
1616
C134726 - Verify middle-clicking pinned tab will close it
1717
"""
1818

19+
# Instantiate objects
1920
example = ExamplePage(driver)
20-
example.open()
2121
tabs = TabBar(driver)
2222
tab_menu = ContextMenu(driver)
2323

2424
# Open 2 new tabs
25+
example.open()
2526
for _ in range(2):
2627
tabs.new_tab_by_button()
2728
tabs.wait_for_num_tabs(3)
2829

2930
# Pin the first tab
30-
with driver.context(driver.CONTEXT_CHROME):
31-
first_tab = tabs.get_tab(1)
32-
tabs.context_click(first_tab)
33-
tab_menu.click_and_hide_menu("context-menu-pin-tab")
34-
assert tabs.is_pinned(first_tab), "Expected the first tab to be pinned"
35-
36-
# Middle-click the pinned tab to close it
37-
tabs.middle_click(first_tab)
31+
first_tab = tabs.get_tab(1)
32+
tabs.context_click(first_tab)
33+
tab_menu.click_and_hide_menu("context-menu-pin-tab")
34+
assert tabs.is_pinned(first_tab), "Expected the first tab to be pinned"
35+
36+
# Middle-click the pinned tab to close it
37+
tabs.middle_click(first_tab)
3838

3939
# Verify pinned tab was closed and 2 tabs remain
4040
tabs.wait_for_num_tabs(2)

tests/tabs/test_close_tab_through_middle_mouse_click.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ def test_close_tab_through_middle_mouse_click(driver: Firefox):
1616
C134645 - Verify that middle clicking a tab will close it
1717
"""
1818

19+
# Instantiate objects
1920
example = ExamplePage(driver)
2021
tabs = TabBar(driver)
21-
example.open()
2222

2323
# Open 2 mnew tabs for a total of 3
24+
example.open()
2425
for _ in range(2):
2526
tabs.new_tab_by_button()
2627
tabs.wait_for_num_tabs(3)
2728

2829
# Ensure each tab exists and middle-click to close it
2930
for i in range(3, 1, -1):
30-
with driver.context(driver.CONTEXT_CHROME):
31-
tab_to_close = tabs.get_tab(i)
32-
assert tab_to_close is not None, f"Expected tab index {i} to exist"
33-
tabs.middle_click(tab_to_close)
31+
tab_to_close = tabs.get_tab(i)
32+
assert tab_to_close is not None, f"Expected tab index {i} to exist"
33+
tabs.middle_click(tab_to_close)
3434
tabs.wait_for_num_tabs(i - 1)

tests/tabs/test_display_customize_button.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ def test_customize_button_displayed_in_tab_bar(driver: Firefox):
1818
and the Customize tab persists when switching tabs.
1919
"""
2020

21+
# Instantiate objects
2122
panel_ui = PanelUi(driver)
2223
tabs = TabBar(driver)
2324
custom_page = CustomizeFirefox(driver)
24-
25-
# Open an initial example page
2625
example = ExamplePage(driver)
27-
example.open()
2826

2927
# Open customize firefox toolbar tab
28+
example.open()
3029
panel_ui.open_panel_menu()
3130
panel_ui.navigate_to_customize_toolbar()
3231

tests/tabs/test_mute_tabs.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ def add_to_prefs_list():
2828
@pytest.mark.audio
2929
def test_mute_unmute_tab(screenshot, driver: Firefox, video_url: str):
3030
"""C134719, test that tabs can be muted and unmuted"""
31+
32+
# Instantiate objects
3133
tabs = TabBar(driver)
34+
35+
# Open the video URL and verify the page title contains "mov_bbb.mp4"
3236
driver.get(video_url)
3337
tabs.expect(EC.title_contains("mov_bbb.mp4"))
3438

35-
with driver.context(driver.CONTEXT_CHROME):
36-
tabs.expect_tab_sound_status(1, tabs.MEDIA_STATUS.PLAYING)
37-
tabs.click_tab_mute_button(1)
38-
tabs.expect_tab_sound_status(1, tabs.MEDIA_STATUS.MUTED)
39-
tabs.click_tab_mute_button(1)
40-
tabs.expect_tab_sound_status(1, tabs.MEDIA_STATUS.PLAYING)
39+
# Check that the tab is currently playing audio and click on mute
40+
tabs.expect_tab_sound_status(1, tabs.MEDIA_STATUS.PLAYING)
41+
tabs.click_tab_mute_button(1)
42+
tabs.expect_tab_sound_status(1, tabs.MEDIA_STATUS.MUTED)
43+
tabs.click_tab_mute_button(1)
44+
tabs.expect_tab_sound_status(1, tabs.MEDIA_STATUS.PLAYING)

tests/tabs/test_navigation_multiple_tabs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from modules.browser_object import TabBar
77

8+
NUM_TABS = 20
89

910
@pytest.fixture()
1011
def test_case():
@@ -14,11 +15,11 @@ def test_case():
1415
def test_navigation_multiple_tabs(driver: Firefox):
1516
"""C134647 - Verify that navigation through multiple tabs is allowed"""
1617

18+
# Instantiate objects
1719
tabs = TabBar(driver)
18-
num_tabs = 20
1920

2021
# Open multiple tabs
21-
for _ in range(num_tabs):
22+
for _ in range(NUM_TABS):
2223
tabs.new_tab_by_button()
2324

2425
with driver.context(driver.CONTEXT_CHROME):

0 commit comments

Comments
 (0)