Skip to content

Commit 287371a

Browse files
committed
Some retouch, improve comments, and visibility
1 parent b896e7d commit 287371a

7 files changed

+51
-48
lines changed

modules/browser_object_panel_ui.py

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,31 @@ def open_private_window(self) -> BasePage:
155155
self.get_element("panel-ui-new-private-window").click()
156156
return self
157157

158+
@BasePage.context_chrome
159+
def redirect_to_about_logins_page(self) -> BasePage:
160+
"""
161+
Opens the about:logins page by clicking the Password option in Hamburger Menu"
162+
"""
163+
self.open_panel_menu()
164+
self.get_element("password-button").click()
165+
return self
166+
167+
@BasePage.context_chrome
168+
def reopen_recently_closed_tabs(self) -> BasePage:
169+
"""Reopen all recently closed tabs"""
170+
self.open_panel_menu()
171+
self.click_on("panel-ui-history")
172+
173+
self.click_on("panel-ui-history-recently-closed")
174+
if self.sys_platform() == "Linux":
175+
sleep(2)
176+
177+
self.click_on("panel-ui-history-recently-closed-reopen-tabs")
178+
179+
return self
180+
181+
# History
182+
158183
@BasePage.context_chrome
159184
def open_history_menu(self) -> BasePage:
160185
"""
@@ -166,9 +191,12 @@ def open_history_menu(self) -> BasePage:
166191

167192
@BasePage.context_chrome
168193
def open_clear_history_dialog(self) -> BasePage:
169-
"""Opens the clear history dialog and switches to iframe context, assuming the history panel is opened"""
194+
"""
195+
Opens the clear history dialog and switches to iframe context, assuming the history panel is opened
196+
"""
170197
self.click_on("clear-recent-history")
171198

199+
# Switch to iframe
172200
self.element_visible("iframe")
173201
iframe = self.get_element("iframe")
174202
BrowserActions(self.driver).switch_to_iframe_context(iframe)
@@ -199,11 +227,9 @@ def verify_most_recent_history_item(self, expected_value: str) -> BasePage:
199227
Argument:
200228
Expected_value (str): The expected value of the most recent history entry
201229
"""
202-
203230
recent_history_items = self.get_elements("recent-history-content")
204231
actual_value = recent_history_items[0].get_attribute("value")
205232
assert actual_value == expected_value
206-
207233
return self
208234

209235
@BasePage.context_chrome
@@ -226,7 +252,6 @@ def get_random_history_entry(self) -> Optional[Tuple[str, str]]:
226252

227253
trimmed_url = self._extract_url_from_history(raw_url)
228254
assert trimmed_url and label, "History item has missing URL or label."
229-
230255
return trimmed_url, label
231256

232257
def _extract_url_from_history(self, raw_url: str) -> str:
@@ -238,20 +263,19 @@ def _extract_url_from_history(self, raw_url: str) -> str:
238263
"""
239264
if not raw_url:
240265
return ""
241-
242266
if "http" in raw_url:
243267
return raw_url[raw_url.find("http") :]
244-
245268
return raw_url.strip()
246269

247270
@BasePage.context_chrome
248-
def redirect_to_about_logins_page(self) -> BasePage:
271+
def confirm_history_clear(self):
249272
"""
250-
Opens the about:logins page by clicking the Password option in Hamburger Menu"
273+
Confirm that the history is empty
251274
"""
252-
self.open_panel_menu()
253-
self.get_element("password-button").click()
254-
return self
275+
self.open_history_menu()
276+
self.expect_element_attribute_contains(
277+
"recent-history-content", "value", "(Empty)"
278+
)
255279

256280
# Bookmarks section
257281

@@ -327,25 +351,3 @@ def get_bookmark_tags(self, tags: List[str]) -> List[str]:
327351
)
328352
for tag in tags
329353
]
330-
331-
@BasePage.context_chrome
332-
def confirm_history_clear(self):
333-
"""Confirm that the history is empty"""
334-
self.open_history_menu()
335-
self.expect_element_attribute_contains(
336-
"recent-history-content", "value", "(Empty)"
337-
)
338-
339-
@BasePage.context_chrome
340-
def reopen_recently_closed_tabs(self) -> BasePage:
341-
"""Reopen all recently closed tabs"""
342-
self.open_panel_menu()
343-
self.click_on("panel-ui-history")
344-
345-
self.click_on("panel-ui-history-recently-closed")
346-
if self.sys_platform() == "Linux":
347-
sleep(2)
348-
349-
self.click_on("panel-ui-history-recently-closed-reopen-tabs")
350-
351-
return self

tests/bookmarks_and_history/test_clear_all_history.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def test_clear_all_history(driver: Firefox):
1919
"""
2020
C172045: Verify that the user can Clear all the History
2121
"""
22-
2322
# Instantiate objects
2423
page = GenericPage(driver)
2524
panel = PanelUi(driver)
@@ -30,7 +29,8 @@ def test_clear_all_history(driver: Firefox):
3029

3130
# Select the option to clear all the history
3231
panel.select_history_time_range_option("Everything")
33-
# A method in panel-ui with selectors moved accordingly would work better, I'll come to this later, couldn't make it work so far
32+
# A method in panel BOM with selectors moved accordingly would make more sense, I'll come to this later,
33+
# there are some context switching + iframe entanglements, couldn't make it work so far
3434
page.click_on("clear-history-button")
3535

3636
# Verify all the history is deleted

tests/bookmarks_and_history/test_clear_recent_history_displayed.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ def test_clear_recent_history_displayed(driver: Firefox):
1313
"""
1414
C172043: Clear recent history panel displayed
1515
"""
16-
1716
# Instantiate object
1817
panel = PanelUi(driver)
1918

tests/bookmarks_and_history/test_open_websites_from_history.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,22 @@ def test_open_websites_from_history(driver: Firefox):
2121
"""
2222
C118807: Verify that the user can open any random website from Hamburger Menu, History section
2323
"""
24-
25-
# Instantiate objects
24+
# Instantiate object
2625
panel = PanelUi(driver)
27-
panel.open_history_menu()
2826

27+
# Open History section from Hamburger Menu and get a random entry from browser history
28+
panel.open_history_menu()
2929
result = panel.get_random_history_entry()
3030

31+
# Skip test if no history entries are available
3132
if result is None:
3233
logging.info("Test skipped: No history available")
3334
return
3435

35-
# Retrieve a random item from history and its label
36+
# Extract URL and page title from the selected history entry
3637
url, label = result
3738

38-
# Open the corresponding page and verify URL and title match
39+
# Navigate to the selected page and verify it loads correctly
3940
page = GenericPage(driver, url=url)
4041
page.open()
4142
page.url_contains(url)

tests/bookmarks_and_history/test_opened_website_in_new_tab_present_in_hamburger_history_menu.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ def test_the_website_opened_in_new_tab_is_present_in_history_menu(driver: Firefo
2828
page = GenericPage(driver, url=WIKIPEDIA_URL)
2929
panel = PanelUi(driver)
3030

31-
# Open a new tab, switch to it and verify is the url contains the desired page name
31+
# Open a desired webpage in a new tab
3232
tabs.open_web_page_in_new_tab(page, 2)
3333
page.url_contains("wikipedia")
3434

35-
# Verify Wikipedia is present in the Hamburger Menu, History section and is on top of the list as the most recent
36-
# website visited
35+
# Verify the opened webpage from last step is present in the Hamburger Menu, History section and is on top of the
36+
# list as the most recent website visited
3737
panel.open_history_menu()
3838
panel.verify_most_recent_history_item("Wikipedia")

tests/bookmarks_and_history/test_opened_website_in_new_window_present_in_hamburger_history_menu.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ def test_the_website_opened_in_new_window_is_present_in_history_menu(driver: Fir
2323
C118805 - Verify that the website opened in new window is displayed in Hamburger Menu, History section, on top of the
2424
list
2525
"""
26-
2726
# Instantiate objects
2827
page = GenericPage(driver, url=WIKIPEDIA_URL)
2928
panel = PanelUi(driver)
3029

31-
# Open a new window, switch to it and verify is the url contains the desired page name
30+
# Open a desired webpage in a new window
3231
panel.open_and_switch_to_new_window("window")
3332
page.open()
3433
page.url_contains("wikipedia")
3534

36-
# Verify Wikipedia is present in the history menu and is on top of the list as the most recent website visited
35+
# Verify the opened webpage from last step is present in the Hamburger Menu, History section and is on top of the
36+
# list as the most recent website visited
3737
panel.open_history_menu()
3838
panel.verify_most_recent_history_item("Wikipedia")

tests/bookmarks_and_history/test_opened_website_present_in_hamburger_history_menu.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def test_the_most_recent_website_is_present_in_history_menu(driver: Firefox):
3030
# Open the desired webpage
3131
page.open()
3232

33-
# Verify Wikipedia is present in the history menu and is on top of the list as the most recent website visited
33+
# Verify the opened webpage from last step is present in the Hamburger Menu, History section and is on top of the
34+
# list as the most recent website visited
3435
panel.open_history_menu()
3536
panel.verify_most_recent_history_item("Wikipedia")

0 commit comments

Comments
 (0)