Skip to content

Commit 7339069

Browse files
authored
fix bookmark test issues (#330)
* fix bookmark test issues * fix additional broken tests * fix additional broken tests * fails in mac gha * fix about config json * fix xfail condition
1 parent fbb5123 commit 7339069

6 files changed

+32
-33
lines changed

modules/data/about_config.components.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@
6060
"selectorData": "changemp",
6161
"strategy": "id",
6262
"groups": []
63+
}
6364
}

modules/page_base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ def opposite_context(self):
116116
else self.driver.CONTEXT_CHROME
117117
)
118118

119+
def is_private(self):
120+
"""Determine if current browsing context is private"""
121+
with self.driver.context(self.driver.CONTEXT_CHROME):
122+
return "Private Browsing" in self.driver.title
123+
119124
def custom_wait(self, **kwargs) -> WebDriverWait:
120125
"""
121126
Create a custom WebDriverWait object, refer to Selenium docs
@@ -671,8 +676,7 @@ def wait_for_num_tabs(self, num_tabs: int) -> Page:
671676

672677
def switch_to_new_tab(self) -> Page:
673678
"""Get list of all window handles, switch to the newly opened tab"""
674-
handles = self.driver.window_handles
675-
self.driver.switch_to.window(handles[-1])
679+
self.driver.switch_to.window(self.driver.window_handles[-1])
676680
return self
677681

678682
def wait_for_num_windows(self, num: int) -> Page:

tests/bookmarks_and_history/test_deleted_page_not_remembered.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
1-
import logging
2-
import platform
3-
from os import environ
4-
51
import pytest
62
from selenium.webdriver import Firefox
73

84
from modules.browser_object import ContextMenu, Navigation, PanelUi
95

10-
X_PADDING = 50
11-
if (
12-
platform.system().lower().startswith("win")
13-
and environ.get("GITHUB_ACTIONS") == "true"
14-
):
15-
X_PADDING += 25
16-
176

187
@pytest.fixture()
198
def test_case():
@@ -25,6 +14,7 @@ def use_profile():
2514
return "theme_change"
2615

2716

17+
@pytest.mark.headed
2818
def test_deleted_page_not_remembered(driver: Firefox, sys_platform):
2919
"""
3020
C216273: Verify that the deleted page from the Hamburger History submenu is not remembered or autofilled in the URL bar
@@ -35,18 +25,7 @@ def test_deleted_page_not_remembered(driver: Firefox, sys_platform):
3525
context_menu = ContextMenu(driver)
3626

3727
panel_ui.open_history_menu()
38-
history_items = panel_ui.get_all_history()
39-
40-
firefox_privacy_notice = history_items[-1]
41-
with driver.context(driver.CONTEXT_CHROME):
42-
x_offset = firefox_privacy_notice.size.get("width") + X_PADDING
43-
logging.info(x_offset)
44-
if sys_platform.lower() == "linux":
45-
panel_ui.click_on(firefox_privacy_notice)
46-
else:
47-
panel_ui.actions.move_to_element_with_offset(
48-
firefox_privacy_notice, x_offset, 0
49-
).click().perform()
28+
panel_ui.context_click("bookmark-by-title", labels=["Firefox Privacy Notice"])
5029

5130
context_menu.click_and_hide_menu("context-menu-delete-page")
5231
nav.type_in_awesome_bar("Firefox Privacy Notice")

tests/bookmarks_and_history/test_open_bookmark_in_new_window_via_toolbar_context_menu.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import platform
2+
from os import environ
3+
14
import pytest
25
from selenium.webdriver import Firefox
36

@@ -13,6 +16,10 @@ def test_case():
1316
URL_TO_BOOKMARK = "https://www.mozilla.org/"
1417

1518

19+
@pytest.mark.xfail(
20+
platform.system() == "Darwin" and environ.get("GITHUB_ACTIONS") == "true",
21+
reason="Test failing in Mac GHA",
22+
)
1623
def test_open_bookmark_in_new_window_via_toolbar_context_menu(driver: Firefox):
1724
"""
1825
C2084552: Verify that a bookmarked page can be open in a New Window from Toolbar context menu.
@@ -35,9 +42,10 @@ def test_open_bookmark_in_new_window_via_toolbar_context_menu(driver: Firefox):
3542
"bookmark-by-title", labels=["Internet for people"]
3643
)
3744
context_menu.context_click(bookmarked_page)
38-
context_menu.get_element("context-menu-toolbar-open-in-new-window").click()
45+
context_menu.click_and_hide_menu("context-menu-toolbar-open-in-new-window")
3946

4047
# Verify that the test page is opened in a new normal window
4148
driver.switch_to.window(driver.window_handles[-1])
42-
nav.element_not_visible("private-browsing-icon")
49+
assert not nav.is_private()
50+
4351
page.url_contains("mozilla")

tests/bookmarks_and_history/test_open_bookmark_in_private_window_via_toolbar_context_menu.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import platform
2+
from os import environ
3+
14
import pytest
25
from selenium.webdriver import Firefox
36

@@ -13,6 +16,10 @@ def test_case():
1316
URL_TO_BOOKMARK = "https://www.mozilla.org/"
1417

1518

19+
@pytest.mark.xfail(
20+
platform.system() == "Darwin" and environ.get("GITHUB_ACTIONS") == "true",
21+
reason="Test failing in Mac GHA",
22+
)
1623
def test_open_bookmark_in_new_private_window_via_toolbar_context_menu(driver: Firefox):
1724
"""
1825
C2084553: Verify that a bookmarked page can be open in a New Private Window from Toolbar context menu.
@@ -36,11 +43,12 @@ def test_open_bookmark_in_new_private_window_via_toolbar_context_menu(driver: Fi
3643
"bookmark-by-title", labels=["Internet for people"]
3744
)
3845
context_menu.context_click(bookmarked_page)
39-
context_menu.get_element(
46+
context_menu.click_and_hide_menu(
4047
"context-menu-toolbar-open-in-new-private-window"
41-
).click()
48+
)
4249

4350
# Verify that the test page is opened in a new private window
4451
driver.switch_to.window(driver.window_handles[-1])
45-
nav.element_visible("private-browsing-icon")
52+
assert nav.is_private()
53+
4654
page.url_contains("mozilla")

tests/security_and_privacy/test_undo_close_tab_private_browsing.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ def test_undo_close_tab_private_browsing(driver: Firefox, sys_platform: str):
5757
tabs.reopen_closed_tab_by_keys(sys_platform)
5858
tabs.wait_for_num_tabs(2)
5959
tabs.switch_to_new_tab()
60-
logging.info(f"The observed title in the chrome context is {driver.title}")
61-
tabs.title_contains("Private Browsing")
60+
assert nav.is_private()
6261

6362
logging.info(f"The observed title in the content context is {driver.title}")
64-
generic_page.title_contains("About About")
63+
generic_page.url_contains("about:about")

0 commit comments

Comments
 (0)