Skip to content

Commit 7e9844b

Browse files
committed
fix test
1 parent 3127e77 commit 7e9844b

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

modules/page_base.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,11 @@ def url_contains(self, url_part: str) -> Page:
391391
self.expect(EC.url_contains(url_part))
392392
return self
393393

394+
def title_contains(self, url_part: str) -> Page:
395+
"""Expect helper: wait until driver URL contains given text or timeout"""
396+
self.expect(EC.title_contains(url_part))
397+
return self
398+
394399
def verify_opened_image_url(self, url_substr: str, pattern: str) -> Page:
395400
"""
396401
Given a part of a URL and a regex, wait for that substring to exist in
@@ -545,11 +550,13 @@ def switch_to_new_tab(self) -> Page:
545550

546551
def wait_for_num_windows(self, num: int) -> Page:
547552
"""Wait for the number of open tabs + windows to equal given int"""
548-
return self.wait_for_num_tabs(num)
553+
with self.driver.context(self.driver.CONTEXT_CONTENT):
554+
return self.wait_for_num_tabs(num)
549555

550556
def switch_to_new_window(self) -> Page:
551557
"""Switch to newest window"""
552-
return self.switch_to_new_tab()
558+
with self.driver.context(self.driver.CONTEXT_CONTENT):
559+
return self.switch_to_new_tab()
553560

554561
def hide_popup(self, context_menu: str, chrome=False) -> Page:
555562
"""

tests/security_and_privacy/test_undo_close_tab_private_browsing.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import logging
2+
13
import pytest
24
from selenium.webdriver import Firefox
35

@@ -24,7 +26,7 @@ def test_undo_close_tab_private_browsing(driver: Firefox, sys_platform: str):
2426

2527
# open a new private window and open a new tab
2628
panel_ui.open_private_window()
27-
tabs.switch_to_new_tab()
29+
tabs.switch_to_new_window()
2830

2931
# open a new tab
3032
tabs.new_tab_by_button()
@@ -48,4 +50,9 @@ def test_undo_close_tab_private_browsing(driver: Firefox, sys_platform: str):
4850
with driver.context(driver.CONTEXT_CHROME):
4951
tabs.reopen_closed_tab_by_keys(sys_platform)
5052
tabs.wait_for_num_tabs(2)
51-
assert driver.title == "About About — Private Browsing"
53+
tabs.switch_to_new_tab()
54+
logging.info(f"The observed title in the chrome context is {driver.title}")
55+
tabs.title_contains("Private Browsing")
56+
57+
logging.info(f"The observed title in the content context is {driver.title}")
58+
generic_page.title_contains("About About")

tests/tabs/test_list_all_tabs.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import logging
2-
from time import sleep
32

4-
import pytest
53
from selenium.webdriver import Firefox
64
from selenium.webdriver.common.keys import Keys
75

tests/tabs/test_navigation_multiple_tabs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22

3-
import pytest
43
from selenium.webdriver import Firefox
54

65
from modules.browser_object import TabBar

0 commit comments

Comments
 (0)