Skip to content

Commit f9e30c4

Browse files
committed
Add open bookmarks tests
1 parent ca03cb3 commit f9e30c4

5 files changed

+84
-57
lines changed

modules/browser_object_navigation.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,3 +544,50 @@ def verify_edit_bookmark_panel_not_visible_after_navigation(self) -> BasePage:
544544
self.click_on("star-button")
545545
self.panel_ui.element_not_visible("show-editor-when-saving-checkbox")
546546
return self
547+
548+
def open_bookmark_from_toolbar(self, bookmark_title: str) -> BasePage:
549+
"""
550+
Right-clicks bookmark and opens it in a new private window via context menu
551+
Arguments:
552+
bookmark_title: The title of the bookmark to open
553+
"""
554+
self.panel_ui.element_clickable("bookmark-by-title", labels=[bookmark_title])
555+
self.panel_ui.context_click("bookmark-by-title", labels=[bookmark_title])
556+
return self
557+
558+
@BasePage.context_chrome
559+
def open_bookmark_in_new_window_via_context_menu(
560+
self, bookmark_title: str
561+
) -> BasePage:
562+
"""
563+
Right-click bookmark and opens it in a new window via context menu
564+
Arguments:
565+
bookmark_title: The title of the bookmark to open
566+
"""
567+
self.panel_ui.element_clickable("bookmark-by-title", labels=[bookmark_title])
568+
self.panel_ui.context_click("bookmark-by-title", labels=[bookmark_title])
569+
self.context_menu.click_on("context-menu-toolbar-open-in-new-window")
570+
return self
571+
572+
@BasePage.context_chrome
573+
def open_bookmark_in_new_private_window_via_context_menu(
574+
self, bookmark_title: str
575+
) -> BasePage:
576+
"""
577+
Right-clicks bookmark and opens it in a new private window via context menu
578+
Arguments:
579+
bookmark_title: The title of the bookmark to open
580+
"""
581+
self.panel_ui.element_clickable("bookmark-by-title", labels=[bookmark_title])
582+
self.panel_ui.context_click("bookmark-by-title", labels=[bookmark_title])
583+
self.context_menu.click_on("context-menu-toolbar-open-in-new-private-window")
584+
return self
585+
586+
@BasePage.context_chrome
587+
def open_all_bookmarks_via_context_menu(self) -> BasePage:
588+
"""
589+
Right-clicks on bookmarks toolbar and opens all bookmarks via context menu
590+
"""
591+
self.context_click("bookmarks-toolbar")
592+
self.context_menu.click_on("context-menu-toolbar-open-all-bookmarks")
593+
return self
Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import pytest
22
from selenium.webdriver import Firefox
33

4-
from modules.browser_object_context_menu import ContextMenu
54
from modules.browser_object_navigation import Navigation
6-
from modules.browser_object_panel_ui import PanelUi
75
from modules.page_object_generics import GenericPage
86

97

@@ -12,40 +10,35 @@ def test_case():
1210
return "2084564"
1311

1412

15-
URL1_TO_BOOKMARK = "https://www.reddit.com/"
16-
URL2_TO_BOOKMARK = "https://www.youtube.com/"
17-
URL3_TO_BOOKMARK = "https://www.mozilla.org/"
18-
URL_NOT_BOOKMARKED = "https://www.wikipedia.org/"
13+
BOOKMARK_URLS = [
14+
"https://www.reddit.com/",
15+
"https://www.youtube.com/",
16+
"https://www.mozilla.org/",
17+
]
18+
UNBOOKMARKED_URL = "https://www.wikipedia.org/"
19+
EXPECTED_URL_SITE_NAME = ["reddit", "youtube", "mozilla"]
1920

2021

2122
def test_open_all_bookmarks_from_bookmarks_toolbar(driver: Firefox):
2223
"""
2324
C2084564: Verify that the user can Open all the bookmarks from the Bookmarks Toolbar
2425
"""
25-
# instantiate object
26+
# Instantiate objects
2627
nav = Navigation(driver)
27-
panel = PanelUi(driver)
28-
context_menu = ContextMenu(driver)
2928
page = GenericPage(driver)
3029

31-
# Have a few Bookmarks saved on the Toolbar
32-
urls_to_bookmark = [URL1_TO_BOOKMARK, URL2_TO_BOOKMARK, URL3_TO_BOOKMARK]
33-
for url in urls_to_bookmark:
30+
# Have a few Bookmarks saved on Toolbar
31+
for url in BOOKMARK_URLS:
3432
GenericPage(driver, url=url).open()
3533
nav.add_bookmark_via_star_icon()
3634

3735
# Load a page that we didn't bookmark, so we can ensure that we're not just picking up on that instance of the page
38-
GenericPage(driver, url=URL_NOT_BOOKMARKED).open()
36+
GenericPage(driver, url=UNBOOKMARKED_URL).open()
3937

40-
# Toggle bookmarks toolbar
41-
# nav.toggle_bookmarks_toolbar_with_key_combo()
42-
43-
# Right-click on a blank space from Bookmarks Toolbar menu and choose open all bookmarks
44-
panel.context_click("bookmarks-toolbar")
45-
context_menu.click_and_hide_menu("context-menu-toolbar-open-all-bookmarks")
38+
# Right-click on a blank space from Bookmarks Toolbar menu and choose Open All Bookmarks from the context menu
39+
nav.open_all_bookmarks_via_context_menu()
4640

4741
# Check that all the bookmarks from the Bookmarks Toolbar are opened in New Tabs
48-
expected_urls = ["reddit", "youtube", "mozilla"]
49-
for index, url_part in enumerate(expected_urls, start=1):
42+
for index, url_site_name in enumerate(EXPECTED_URL_SITE_NAME, start=1):
5043
driver.switch_to.window(driver.window_handles[index])
51-
page.url_contains(url_part)
44+
page.url_contains(url_site_name)
Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from selenium.webdriver import Firefox
33

4-
from modules.browser_object import ContextMenu, Navigation, PanelUi, TabBar
4+
from modules.browser_object import Navigation, TabBar
55
from modules.page_object_generics import GenericPage
66

77

@@ -10,35 +10,30 @@ def test_case():
1010
return "2084552"
1111

1212

13-
URL_TO_BOOKMARK = "https://www.mozilla.org/"
13+
BOOKMARK_URL = "https://www.mozilla.org/"
14+
BOOKMARK_TITLE = "Internet for people"
1415

1516

1617
def test_open_bookmark_in_new_window_via_toolbar_context_menu(driver: Firefox):
1718
"""
1819
C2084552: Verify that a bookmarked page can be open in a New Window from Toolbar context menu.
1920
"""
2021

21-
# Instantiate object
22+
# Instantiate objects
2223
nav = Navigation(driver)
23-
panel = PanelUi(driver)
2424
tabs = TabBar(driver)
25-
context_menu = ContextMenu(driver)
26-
page = GenericPage(driver, url=URL_TO_BOOKMARK)
25+
page = GenericPage(driver, url=BOOKMARK_URL)
2726

2827
# Bookmark the test page via star button
2928
page.open()
3029
nav.add_bookmark_via_star_icon()
3130

32-
# In a new tab, right-click the bookmarked page in the toolbar and select 'Open in New Window' from the context menu
33-
with driver.context(driver.CONTEXT_CHROME):
34-
tabs.new_tab_by_button()
35-
panel.element_clickable("bookmark-by-title", labels=["Internet for people"])
36-
panel.context_click("bookmark-by-title", labels=["Internet for people"])
37-
context_menu.click_and_hide_menu("context-menu-toolbar-open-in-new-window")
31+
# In a new tab, right-click the bookmarked page in the toolbar and select Open in New Window from the context menu
32+
tabs.new_tab_by_button()
33+
nav.open_bookmark_in_new_window_via_context_menu(BOOKMARK_TITLE)
3834

3935
# Verify that the test page is opened in a new normal window
4036
tabs.wait_for_num_tabs(3)
4137
driver.switch_to.window(driver.window_handles[-1])
4238
assert not nav.is_private()
43-
4439
page.url_contains("mozilla")

tests/bookmarks_and_history/test_open_bookmark_in_private_window_via_toolbar_context_menu.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,28 @@ def test_case():
1010
return "2084553"
1111

1212

13-
URL_TO_BOOKMARK = "https://www.mozilla.org/"
13+
BOOKMARK_URL = "https://www.mozilla.org/"
14+
BOOKMARK_TITLE = "Internet for people"
1415

1516

1617
def test_open_bookmark_in_new_private_window_via_toolbar_context_menu(driver: Firefox):
1718
"""
1819
C2084553: Verify that a bookmarked page can be open in a New Private Window from Toolbar context menu.
1920
"""
2021

21-
# Instantiate object
22+
# Instantiate objects
2223
nav = Navigation(driver)
23-
panel = PanelUi(driver)
2424
tabs = TabBar(driver)
25-
context_menu = ContextMenu(driver)
26-
page = GenericPage(driver, url=URL_TO_BOOKMARK)
25+
page = GenericPage(driver, url=BOOKMARK_URL)
2726

2827
# Bookmark the test page via star button
2928
page.open()
3029
nav.add_bookmark_via_star_icon()
3130

3231
# In a new tab, right-click the bookmarked page in the toolbar and select 'Open in New Private Window' from the
3332
# context menu
34-
with driver.context(driver.CONTEXT_CHROME):
35-
tabs.new_tab_by_button()
36-
panel.element_clickable("bookmark-by-title", labels=["Internet for people"])
37-
panel.context_click("bookmark-by-title", labels=["Internet for people"])
38-
context_menu.click_and_hide_menu(
39-
"context-menu-toolbar-open-in-new-private-window"
40-
)
33+
tabs.new_tab_by_button()
34+
nav.open_bookmark_in_new_private_window_via_context_menu(BOOKMARK_TITLE)
4135

4236
# Verify that the test page is opened in a new private window
4337
tabs.wait_for_num_tabs(3)

tests/bookmarks_and_history/test_open_bookmarks_from_toolbar.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from selenium.webdriver import Firefox
33

44
from modules.browser_object_navigation import Navigation
5-
from modules.browser_object_panel_ui import PanelUi
65
from modules.browser_object_tabbar import TabBar
76
from modules.page_object_generics import GenericPage
87

@@ -12,27 +11,26 @@ def test_case():
1211
return "2084550"
1312

1413

15-
URL_TO_BOOKMARK = "https://www.mozilla.org/"
14+
BOOKMARK_URL = "https://www.mozilla.org/"
15+
BOOKMARK_TITLE = "Internet for people"
1616

1717

1818
def test_open_bookmarks_from_toolbar(driver: Firefox):
1919
"""
2020
C2084550: Verify that the user can open Bookmarks from the Toolbar with a mouse click
2121
"""
22-
# instantiate object
22+
# Instantiate object
2323
nav = Navigation(driver)
24-
panel = PanelUi(driver)
25-
newtab = TabBar(driver)
26-
page = GenericPage(driver, url=URL_TO_BOOKMARK)
24+
tab = TabBar(driver)
25+
page = GenericPage(driver, url=BOOKMARK_URL)
2726

2827
# Bookmark the given website via star button
29-
driver.get(URL_TO_BOOKMARK)
28+
page.open()
3029
nav.add_bookmark_via_star_icon()
3130

3231
# Open new tab and click on the bookmark from the Bookmarks Toolbar
33-
with driver.context(driver.CONTEXT_CHROME):
34-
newtab.new_tab_by_button()
35-
panel.get_element("bookmark-by-title", labels=["Internet for people"]).click()
32+
tab.new_tab_by_button()
33+
nav.open_bookmark_from_toolbar(BOOKMARK_TITLE)
3634

3735
# Verify that the page is loaded
3836
page.title_contains("Internet for people")

0 commit comments

Comments
 (0)