Skip to content

Commit ca03cb3

Browse files
committed
Add edit tests
1 parent c970ae8 commit ca03cb3

11 files changed

+181
-90
lines changed

SELECTOR_INFO.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2755,13 +2755,6 @@ Location: Download panel
27552755
Path to .json: modules/data/navigation.components.json
27562756
```
27572757
```
2758-
Selector name: edit-bookmark-panel
2759-
Selector Data: editBMPanel_namePicker
2760-
Description: Edit bookmark panel
2761-
Location: Bookmark panel
2762-
Path to .json: modules/data/navigation.components.json
2763-
```
2764-
```
27652758
Selector name: remove-bookmark-button
27662759
Selector Data: editBookmarkPanelRemoveButton
27672760
Description: Remove bookmark button
@@ -3392,6 +3385,14 @@ Description: Bookmarks toolbar
33923385
Location: Bookmarks toolbar
33933386
Path to .json: modules/data/panel_ui.components.json
33943387
```
3388+
```
3389+
Selector name: edit-bookmark-panel
3390+
Selector Data: editBMPanel_namePicker
3391+
Description: Edit bookmark panel
3392+
Location: Bookmark panel
3393+
Path to .json: modules/data/pane_ui.components.json
3394+
```
3395+
```
33953396
#### print_preview
33963397
```
33973398
Selector name: print-preview-browser

modules/browser_object_navigation.py

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,13 @@ def bookmark_page_in_other_bookmarks(self) -> BasePage:
359359
def add_bookmark_via_toolbar_other_bookmark_context_menu(
360360
self, bookmark_data: Bookmark, ba: BrowserActions
361361
) -> BasePage:
362-
"""Add a bookmark via the toolbar's Other Bookmarks context menu."""
362+
"""
363+
Add a bookmark via the toolbar's Other Bookmarks context menu.
364+
Arguments
365+
----------
366+
bookmark_data : A Bookmark object containing the bookmark details to be added (name, url, tags, keyword)
367+
ba : BrowserActions utility
368+
"""
363369
iframe = self.get_element("bookmark-iframe")
364370
ba.switch_to_iframe_context(iframe)
365371
# fill name
@@ -424,9 +430,11 @@ def open_add_bookmark_via_toolbar_other_bookmarks_context_menu(self) -> BasePage
424430
def delete_bookmark_from_other_bookmarks_via_context_menu(
425431
self, bookmark_name: str
426432
) -> BasePage:
427-
"""Deletes a bookmark from Other Bookmarks via context menu.
433+
"""
434+
Deletes a bookmark from Other Bookmarks via context menu.
428435
Argument:
429-
bookmark_name: The display name of the bookmark to delete
436+
----------
437+
bookmark_name: The display name of the bookmark to delete
430438
"""
431439
self.click_on("other-bookmarks-toolbar")
432440
self.panel_ui.context_click("other-bookmarks-by-title", labels=[bookmark_name])
@@ -435,7 +443,12 @@ def delete_bookmark_from_other_bookmarks_via_context_menu(
435443

436444
@BasePage.context_chrome
437445
def delete_bookmark_from_bookmarks_toolbar(self, bookmark_name: str) -> BasePage:
438-
"""Delete bookmark from bookmarks toolbar via context menu"""
446+
"""
447+
Delete bookmark from bookmarks toolbar via context menu
448+
Argument:
449+
----------
450+
bookmark_name: The display name of the bookmark to delete
451+
"""
439452
self.panel_ui.context_click("bookmark-by-title", labels=[bookmark_name])
440453
self.context_menu.click_and_hide_menu("context-menu-delete-page")
441454
return self
@@ -444,7 +457,12 @@ def delete_bookmark_from_bookmarks_toolbar(self, bookmark_name: str) -> BasePage
444457
def verify_bookmark_exists_in_toolbar_other_bookmarks_folder(
445458
self, bookmark_name: str
446459
) -> BasePage:
447-
"""Verify bookmark exists in Other Bookmarks folder from toolbar"""
460+
"""
461+
Verify bookmark exists in Other Bookmarks folder from toolbar
462+
Arguments
463+
----------
464+
bookmark_name : The exact name/title of the bookmark to search for in the Other Bookmarks folder.
465+
"""
448466
self.click_on("other-bookmarks-toolbar") # Navigation selector
449467
self.panel_ui.element_visible(
450468
"other-bookmarks-by-title", labels=[bookmark_name]
@@ -455,15 +473,22 @@ def verify_bookmark_exists_in_toolbar_other_bookmarks_folder(
455473
def verify_bookmark_exists_in_bookmarks_toolbar(
456474
self, bookmark_name: str
457475
) -> BasePage:
458-
"""Verify bookmark exists in the bookmarks toolbar"""
476+
"""
477+
Verify bookmark exists in the bookmarks toolbar
478+
"""
459479
self.panel_ui.element_visible("bookmark-by-title", labels=[bookmark_name])
460480
return self
461481

462482
@BasePage.context_chrome
463483
def verify_bookmark_does_not_exist_in_toolbar_other_bookmarks_folder(
464484
self, bookmark_name: str
465485
) -> BasePage:
466-
"""Verify bookmark does not exist in Other Bookmarks folder from toolbar"""
486+
"""
487+
Verify bookmark does not exist in Other Bookmarks folder from toolbar
488+
Arguments
489+
----------
490+
bookmark_name : The exact name/title of the bookmark to search for in the Other Bookmarks folder.
491+
"""
467492
self.click_on("other-bookmarks-toolbar")
468493
self.panel_ui.element_not_visible(
469494
"other-bookmarks-by-title", labels=[bookmark_name]
@@ -477,3 +502,45 @@ def verify_bookmark_does_not_exist_in_bookmarks_toolbar(
477502
"""Verify bookmark does not exist in the bookmarks toolbar"""
478503
self.panel_ui.element_not_visible("bookmark-by-title", labels=[bookmark_name])
479504
return self
505+
506+
@BasePage.context_chrome
507+
def edit_bookmark_via_star_button(self, new_name: str, location: str) -> BasePage:
508+
"""
509+
Edit bookmark details by opening the edit bookmark panel via the star button
510+
Arguments
511+
----------
512+
new_name : str
513+
The new name/title to assign to the bookmark
514+
location : str
515+
The folder location where the bookmark should be saved
516+
"""
517+
self.click_on("star-button")
518+
self.panel_ui.get_element("edit-bookmark-panel").send_keys(new_name)
519+
if location == "Other Bookmarks":
520+
self.panel_ui.click_on("bookmark-location")
521+
self.panel_ui.click_on("other-bookmarks")
522+
elif location == "Bookmarks Toolbar":
523+
self.panel_ui.click_on("bookmark-location")
524+
self.panel_ui.click_on("bookmarks-toolbar")
525+
self.panel_ui.click_on("save-bookmark-button")
526+
return self
527+
528+
@BasePage.context_chrome
529+
def toggle_show_editor_when_saving(self) -> BasePage:
530+
"""
531+
Toggle the show editor checkbox
532+
"""
533+
self.click_on("star-button")
534+
self.panel_ui.click_on("show-editor-when-saving-checkbox")
535+
self.panel_ui.click_on("save-bookmark-button")
536+
return self
537+
538+
@BasePage.context_chrome
539+
def verify_edit_bookmark_panel_not_visible_after_navigation(self) -> BasePage:
540+
"""
541+
Navigate to new URL and verify that edit bookmark panel is not visible when clicking star
542+
Uses the exact same pattern as the working test
543+
"""
544+
self.click_on("star-button")
545+
self.panel_ui.element_not_visible("show-editor-when-saving-checkbox")
546+
return self

modules/browser_object_panel_ui.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class PanelUi(BasePage):
1414
"""Browser Object Model for nav panel UI menu (hamburger menu, application menu)"""
1515

1616
URL_TEMPLATE = "about:blank"
17+
ENABLE_ADD_TAG = (
18+
"""PlacesUtils.tagging.tagURI(makeURI("https://www.github.com"), ["tag1"]);"""
19+
)
1720

1821
class Menu(Region):
1922
"""
@@ -214,3 +217,45 @@ def verify_bookmark_exists_in_hamburger_menu(self, bookmark_title: str) -> BaseP
214217
"""
215218
self.element_visible("bookmark-by-title", labels=[bookmark_title])
216219
return self
220+
221+
@BasePage.context_chrome
222+
def enable_bookmark_tagging(self) -> BasePage:
223+
"""
224+
Enable tagging functionality for bookmarks by executing a script
225+
"""
226+
self.driver.execute_script(self.ENABLE_ADD_TAG)
227+
return self
228+
229+
@BasePage.context_chrome
230+
def edit_bookmark_from_hamburger_menu(
231+
self, new_name: str, tags: str, location: str
232+
) -> BasePage:
233+
"""Edit bookmark details from hamburger menu"""
234+
self.open_bookmarks_panel_from_hamburger_menu()
235+
self.click_on("bookmark-current-tab")
236+
237+
# Edit bookmark details
238+
self.get_element("edit-bookmark-panel").send_keys(new_name)
239+
self.get_element("bookmark-tags").send_keys(tags)
240+
if location == "Other Bookmarks":
241+
self.click_on("bookmark-location")
242+
self.click_on("other-bookmarks")
243+
elif location == "Bookmarks Toolbar":
244+
self.click_on("bookmark-location")
245+
self.click_on("bookmarks-toolbar")
246+
self.click_on("save-bookmark-button")
247+
248+
@BasePage.context_chrome
249+
def get_bookmark_tags(self, tags: List[str]) -> List[str]:
250+
"""
251+
Returns the actual bookmark tag values from the UI
252+
"""
253+
self.open_bookmarks_panel_from_hamburger_menu()
254+
self.click_on("bookmark-current-tab")
255+
self.click_on("extend-bookmark-tags")
256+
return [
257+
self.get_element(f"{tag.lower().replace(' ', '')}-tag").get_attribute(
258+
"value"
259+
)
260+
for tag in tags
261+
]

modules/data/navigation.components.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,6 @@
284284
"groups": []
285285
},
286286

287-
"edit-bookmark-panel": {
288-
"selectorData": "editBMPanel_namePicker",
289-
"strategy": "id",
290-
"groups": []
291-
},
292-
293287
"remove-bookmark-button": {
294288
"selectorData": "editBookmarkPanelRemoveButton",
295289
"strategy": "id",

modules/data/panel_ui.components.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,5 +317,11 @@
317317
"selectorData": "editBookmarkPanelDoneButton",
318318
"strategy": "id",
319319
"groups": []
320+
},
321+
322+
"edit-bookmark-panel": {
323+
"selectorData": "editBMPanel_namePicker",
324+
"strategy": "id",
325+
"groups": []
320326
}
321327
}

tests/bookmarks_and_history/test_add_new_other_bookmark.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def test_add_new_other_bookmark(driver: Firefox):
2020
C2084518 - Verify another bookmark (with name, url, tag, keyword) can be added from other bookmarks toolbar
2121
context menu
2222
"""
23+
# Instantiate objects
2324
nav = Navigation(driver)
2425
ba = BrowserActions(driver)
2526
page = GenericPage(driver, url=BOOKMARK.url)

tests/bookmarks_and_history/test_bookmark_via_bookmark_menu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_bookmark_via_hamburger_menu(driver: Firefox):
1818
"""
1919
C2084489: Verify that the user can bookmark a page using Bookmark current tab .. opened from Hamburger Menu
2020
"""
21-
# Instantiate object
21+
# Instantiate objects
2222
panel = PanelUi(driver)
2323
page = GenericPage(driver, url=BOOKMARK_URL)
2424

tests/bookmarks_and_history/test_bookmark_website_via_star_button.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_bookmark_website_via_star(driver: Firefox):
2020
"""
2121
C2084539: Verify that the Websites can be bookmarked via star-shaped button
2222
"""
23-
# Instantiate object
23+
# Instantiate objects
2424
nav = Navigation(driver)
2525
panel = PanelUi(driver)
2626
page = GenericPage(driver, url=BOOKMARK_URL)

tests/bookmarks_and_history/test_delete_other_bookmarks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def test_delete_other_bookmarks(driver: Firefox):
2121
"""
2222
C2084524 - Verify that a user can Delete a bookmark from 'Other Bookmarks' folder
2323
"""
24+
# Instantiate objects
2425
nav = Navigation(driver)
2526
page = GenericPage(driver, url=CACHE_PAGE_URL)
2627
ba = BrowserActions(driver)

tests/bookmarks_and_history/test_edit_bookmark_from_bookmark_menu.py

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,57 +11,38 @@ def test_case():
1111
return "2084490"
1212

1313

14-
URL_TO_BOOKMARK = "https://www.mozilla.org/"
15-
URL_TO_SAVE = "https://monitor.mozilla.org/"
16-
ENABLE_ADD_TAG = """
17-
PlacesUtils.tagging.tagURI(makeURI("https://www.github.com"), ["tag1"]);
18-
"""
14+
BOOKMARK_URL = "https://www.mozilla.org/"
15+
BOOKMARK_NAME = "Mozilla Firefox"
16+
BOOKMARK_LOCATION = "Other Bookmarks"
17+
BOOKMARK_TAGS_STR = "Work, To do"
18+
BOOKMARK_TAGS_LIST = ["Work", "To do"]
1919

2020

2121
def test_edit_bookmark_from_bookmark_menu(driver: Firefox):
2222
"""
2323
C2084490: Verify that the user can Edit a Bookmark from Bookmarks menu
2424
"""
25-
# instantiate object
25+
# Instantiate objects
2626
nav = Navigation(driver)
2727
panel = PanelUi(driver)
28+
page = GenericPage(driver, url=BOOKMARK_URL)
2829

29-
# Bookmark the given website via bookmarks menu
30-
GenericPage(driver, url=URL_TO_BOOKMARK).open()
30+
# Bookmark using Bookmark current tab option from Hamburger Menu
31+
page.open()
3132
panel.open_bookmarks_panel_from_hamburger_menu()
32-
nav.add_bookmark_via_star_icon()
33+
panel.bookmark_current_tab_via_hamburger_menu()
3334

34-
with driver.context(driver.CONTEXT_CHROME):
35-
# enable add a tag to a bookmark in the bookmark panel
36-
driver.execute_script(ENABLE_ADD_TAG)
35+
# Enable bookmark tagging functionality
36+
panel.enable_bookmark_tagging()
3737

38-
# Open the Hamburger menu, click on the Edit This Bookmark button from the Bookmarks section
39-
panel.open_bookmarks_panel_from_hamburger_menu()
40-
panel.get_element("bookmark-current-tab").click()
38+
# Edit bookmark details via Hamburger Menu
39+
panel.edit_bookmark_from_hamburger_menu(
40+
new_name=BOOKMARK_NAME, tags=BOOKMARK_TAGS_STR, location=BOOKMARK_LOCATION
41+
)
4142

42-
# Change bookmark name, location and add a tag
43-
nav.get_element("edit-bookmark-panel").send_keys("Mozilla Firefox")
44-
panel.get_element("bookmark-tags").send_keys("Work, To do")
45-
panel.get_element("bookmark-location").click()
46-
panel.get_element("other-bookmarks").click()
47-
nav.get_element("save-bookmark-button").click()
43+
# Verify bookmark was moved to Other Bookmarks with correct name
44+
nav.verify_bookmark_exists_in_toolbar_other_bookmarks_folder(BOOKMARK_NAME)
4845

49-
# Temporary fix before the other bookmarks issue is fixed
50-
nav.get_element("star-button").click()
51-
assert (
52-
panel.get_element("bookmark-location").get_attribute("label")
53-
== "Other Bookmarks"
54-
)
55-
# Check bookmark name and location are changed in the bookmarks toolbar
56-
# panel.get_element("other-bookmarks-toolbar").click()
57-
# panel.element_visible("other-bookmarks-by-title", labels=["Mozilla Firefox"])
58-
# panel.get_element("other-bookmarks-toolbar").click()
59-
60-
# Check tags are correctly added and checked
61-
panel.get_element("extend-bookmark-tags").click()
62-
work_checkbox = panel.get_element("work-tag")
63-
work_checked_attr = work_checkbox.get_attribute("checked")
64-
assert work_checked_attr is None
65-
todo_checkbox = panel.get_element("todo-tag")
66-
todo_checked_attr = todo_checkbox.get_attribute("checked")
67-
assert todo_checked_attr is None
46+
# Verify bookmark tags are set correctly
47+
actual_tags = panel.get_bookmark_tags(BOOKMARK_TAGS_LIST)
48+
assert actual_tags == BOOKMARK_TAGS_LIST

0 commit comments

Comments
 (0)