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
10 changes: 10 additions & 0 deletions modules/browser_object_tabbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,13 @@ def open_multiple_tabs_with_pages(self, pages: list) -> "TabBar":
else:
page.open()
return self

@BasePage.context_chrome
def verify_tab_focus_cycle(self, num_tabs: int):
"""Go through all the tabs and ensure the focus changes correctly."""
for i in range(1, num_tabs + 2):
target_tab = self.get_tab(i)
self.click_on(target_tab)
self.custom_wait(timeout=3).until(
lambda d: target_tab.get_attribute("visuallyselected") == ""
)
16 changes: 7 additions & 9 deletions tests/tabs/test_active_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from modules.browser_object import TabBar


NUM_TABS = 5


@pytest.fixture()
def test_case():
return "134646"
Expand All @@ -14,18 +17,13 @@ def test_active_tab(driver: Firefox):
"""
C134646, ensures that the selected tab is highlighted
"""

# Instantiate objects
tabs = TabBar(driver)
num_tabs = 5

# Open 5 tabs
for i in range(num_tabs):
for i in range(NUM_TABS):
tabs.new_tab_by_button()

# Go through all the tabs and ensure the focus is correct
for i in range(1, num_tabs + 2):
with driver.context(driver.CONTEXT_CHROME):
target_tab = tabs.get_tab(i)
target_tab.click()
tabs.custom_wait(timeout=3).until(
lambda d: target_tab.get_attribute("visuallyselected") == ""
)
tabs.verify_tab_focus_cycle(NUM_TABS)
18 changes: 9 additions & 9 deletions tests/tabs/test_close_pinned_tab_via_mouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ def test_close_pinned_tab_via_middle_click(driver: Firefox):
C134726 - Verify middle-clicking pinned tab will close it
"""

# Instantiate objects
example = ExamplePage(driver)
example.open()
tabs = TabBar(driver)
tab_menu = ContextMenu(driver)

# Open 2 new tabs
example.open()
for _ in range(2):
tabs.new_tab_by_button()
tabs.wait_for_num_tabs(3)

# Pin the first tab
with driver.context(driver.CONTEXT_CHROME):
first_tab = tabs.get_tab(1)
tabs.context_click(first_tab)
tab_menu.click_and_hide_menu("context-menu-pin-tab")
assert tabs.is_pinned(first_tab), "Expected the first tab to be pinned"

# Middle-click the pinned tab to close it
tabs.middle_click(first_tab)
first_tab = tabs.get_tab(1)
tabs.context_click(first_tab)
tab_menu.click_and_hide_menu("context-menu-pin-tab")
assert tabs.is_pinned(first_tab), "Expected the first tab to be pinned"

# Middle-click the pinned tab to close it
tabs.middle_click(first_tab)

# Verify pinned tab was closed and 2 tabs remain
tabs.wait_for_num_tabs(2)
10 changes: 5 additions & 5 deletions tests/tabs/test_close_tab_through_middle_mouse_click.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ def test_close_tab_through_middle_mouse_click(driver: Firefox):
C134645 - Verify that middle clicking a tab will close it
"""

# Instantiate objects
example = ExamplePage(driver)
tabs = TabBar(driver)
example.open()

# Open 2 mnew tabs for a total of 3
example.open()
for _ in range(2):
tabs.new_tab_by_button()
tabs.wait_for_num_tabs(3)

# Ensure each tab exists and middle-click to close it
for i in range(3, 1, -1):
with driver.context(driver.CONTEXT_CHROME):
tab_to_close = tabs.get_tab(i)
assert tab_to_close is not None, f"Expected tab index {i} to exist"
tabs.middle_click(tab_to_close)
tab_to_close = tabs.get_tab(i)
assert tab_to_close is not None, f"Expected tab index {i} to exist"
tabs.middle_click(tab_to_close)
tabs.wait_for_num_tabs(i - 1)
5 changes: 2 additions & 3 deletions tests/tabs/test_display_customize_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ def test_customize_button_displayed_in_tab_bar(driver: Firefox):
and the Customize tab persists when switching tabs.
"""

# Instantiate objects
panel_ui = PanelUi(driver)
tabs = TabBar(driver)
custom_page = CustomizeFirefox(driver)

# Open an initial example page
example = ExamplePage(driver)
example.open()

# Open customize firefox toolbar tab
example.open()
panel_ui.open_panel_menu()
panel_ui.navigate_to_customize_toolbar()

Expand Down
16 changes: 10 additions & 6 deletions tests/tabs/test_mute_tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ def add_to_prefs_list():
@pytest.mark.audio
def test_mute_unmute_tab(screenshot, driver: Firefox, video_url: str):
"""C134719, test that tabs can be muted and unmuted"""

# Instantiate objects
tabs = TabBar(driver)

# Open the video URL and verify the page title contains "mov_bbb.mp4"
driver.get(video_url)
tabs.expect(EC.title_contains("mov_bbb.mp4"))

with driver.context(driver.CONTEXT_CHROME):
tabs.expect_tab_sound_status(1, tabs.MEDIA_STATUS.PLAYING)
tabs.click_tab_mute_button(1)
tabs.expect_tab_sound_status(1, tabs.MEDIA_STATUS.MUTED)
tabs.click_tab_mute_button(1)
tabs.expect_tab_sound_status(1, tabs.MEDIA_STATUS.PLAYING)
# Check that the tab is currently playing audio and click on mute
tabs.expect_tab_sound_status(1, tabs.MEDIA_STATUS.PLAYING)
tabs.click_tab_mute_button(1)
tabs.expect_tab_sound_status(1, tabs.MEDIA_STATUS.MUTED)
tabs.click_tab_mute_button(1)
tabs.expect_tab_sound_status(1, tabs.MEDIA_STATUS.PLAYING)
8 changes: 4 additions & 4 deletions tests/tabs/test_navigation_multiple_tabs.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging

import pytest
from selenium.webdriver import Firefox

from modules.browser_object import TabBar

NUM_TABS = 20


@pytest.fixture()
def test_case():
Expand All @@ -14,11 +14,11 @@ def test_case():
def test_navigation_multiple_tabs(driver: Firefox):
"""C134647 - Verify that navigation through multiple tabs is allowed"""

# Instantiate objects
tabs = TabBar(driver)
num_tabs = 20

# Open multiple tabs
for _ in range(num_tabs):
for _ in range(NUM_TABS):
tabs.new_tab_by_button()

with driver.context(driver.CONTEXT_CHROME):
Expand Down
8 changes: 5 additions & 3 deletions tests/tabs/test_open_bookmark_in_new_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ def test_case():

BOOKMARK_URL = "https://www.youtube.com/"
BOOKMARK_TITLE = "YouTube"
EXPECTED_TEST = "youtube"


def test_open_bookmark_in_new_tab(driver: Firefox):

"""
C134460: Verify that New Tabs can be opened by right clicking and selecting new tab from the bookmarks.
"""
Expand All @@ -39,6 +41,6 @@ def test_open_bookmark_in_new_tab(driver: Firefox):
tabs.wait_for_num_tabs(3)
driver.switch_to.window(driver.window_handles[-1])

WebDriverWait(driver, 5).until(EC.url_contains("youtube"))
assert "youtube" in driver.current_url
page.url_contains("youtube")
WebDriverWait(driver, 5).until(EC.url_contains(EXPECTED_TEST))
assert EXPECTED_TEST in driver.current_url
page.url_contains(EXPECTED_TEST)
14 changes: 11 additions & 3 deletions tests/tabs/test_open_new_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
from modules.browser_object import TabBar


URL = "about:robots"
EXPECTED_TEXT = "Firefox"


@pytest.fixture()
def test_case():
return "134453"
Expand All @@ -14,11 +18,15 @@ def test_open_new_tab_plus(driver: Firefox):
"""
C134453 - A new tab can be opened from the dedicated button ("+")
"""

# Instantiate object
browser = TabBar(driver)
driver.get("about:robots")

# Open page and check a new tab can be opened from the dedicated button ("+")
driver.get(URL)
browser.set_chrome_context()
browser.new_tab_by_button()
browser.expect(EC.title_contains("Firefox"))
assert "Firefox" in driver.title, (
browser.expect(EC.title_contains(EXPECTED_TEXT))
assert EXPECTED_TEXT in driver.title, (
f"Expected title to contain 'Firefox', but got '{driver.title}'"
)
15 changes: 11 additions & 4 deletions tests/tabs/test_open_new_tab_keys.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import pytest
from selenium.webdriver import Firefox
from selenium.webdriver.support import expected_conditions as EC

from modules.browser_object import TabBar


URL = "about:robots"
EXPECTED_TEXT = "Firefox"


@pytest.fixture()
def test_case():
return "134442"
Expand All @@ -14,11 +17,15 @@ def test_open_new_tab_via_keyboard(driver: Firefox, sys_platform: str):
"""
C134442 - A new tab can be opened via keyboard combinations
"""

# Instantiate object
browser = TabBar(driver)
driver.get("about:robots")

# Open page and check a new tab can be opened via keyboard combinations
driver.get(URL)
browser.set_chrome_context()
browser.new_tab_by_keys(sys_platform)
browser.expect(EC.title_contains("Firefox"))
assert "Firefox" in driver.title, (
browser.expect(EC.title_contains(EXPECTED_TEXT))
assert EXPECTED_TEXT in driver.title, (
f"Expected title to contain 'Firefox', but got '{driver.title}'"
)