1
- from time import sleep
2
-
3
1
import pytest
4
2
from selenium .webdriver import Firefox
5
- from selenium .webdriver .common .keys import Keys
6
3
7
4
from modules .browser_object import Navigation , PanelUi , TabBar
5
+ from modules .page_object import GenericPage
8
6
9
7
VISIT_URL = "about:about"
10
8
11
- links = [
12
- "about:about" ,
13
- "about:addons" ,
14
- "about:cache" ,
15
- "about:config" ,
16
- "about:buildconfig" ,
17
- "about:robots" ,
18
- "about:blank" ,
19
- ]
20
-
21
- link_set = set (links )
22
-
23
9
24
10
@pytest .fixture ()
25
11
def add_prefs ():
26
12
return []
27
13
28
14
29
- def test_undo_close_tab_private_browsing (driver : Firefox ):
15
+ def test_undo_close_tab_private_browsing (driver : Firefox , sys_platform : str ):
30
16
"""
31
17
C120118: ensure that you can close a tab in private browsing window
32
18
"""
33
19
# instantiate objs
34
- panel_ui = PanelUi (driver )
35
- nav = Navigation (driver ). open ()
20
+ panel_ui = PanelUi (driver ). open ()
21
+ nav = Navigation (driver )
36
22
tabs = TabBar (driver )
23
+ generic_page = GenericPage (driver , url = "about:about" )
37
24
38
25
# open a new private window and open a new tab
39
26
panel_ui .open_private_window ()
@@ -43,16 +30,24 @@ def test_undo_close_tab_private_browsing(driver: Firefox):
43
30
tabs .new_tab_by_button ()
44
31
tabs .switch_to_new_tab ()
45
32
46
- # navigate to the URL NOTE: TEMPORARY GET AWESOME BAR PRIVATE. ADD SUPPORT FOR IT IN NAVIGATION
33
+ # navigate to the URL
47
34
with driver .context (driver .CONTEXT_CHROME ):
48
- search_bar = nav .get_element ("awesome-bar-private" )
49
- search_bar .send_keys (VISIT_URL + Keys .ENTER )
50
- tabs .wait_for_num_tabs (3 )
51
- # tabs.switch_to_new_tab()
52
- # for _ in range(100):
53
- # print(len(driver.window_handles))
54
- # sleep(0.5)
35
+ nav .search (VISIT_URL )
55
36
56
- tabs .close_tab_of_index (0 )
37
+ # ensure its loaded
38
+ generic_page .url_contains ("about:about" )
57
39
58
- sleep (40 )
40
+ # close the most recent window
41
+ with driver .context (driver .CONTEXT_CHROME ):
42
+ cur_tab = tabs .get_tab_by_title ("About About" )
43
+ tabs .close_tab (cur_tab )
44
+
45
+ # ensuring that one of the tabs was closed properly
46
+ tabs .wait_for_num_tabs (2 )
47
+ assert len (driver .window_handles ) == 2
48
+
49
+ # ensure the last tab can be reopened
50
+ with driver .context (driver .CONTEXT_CHROME ):
51
+ tabs .reopen_closed_tab_by_keys (sys_platform )
52
+ tabs .wait_for_num_tabs (2 )
53
+ assert driver .title == "About About — Private Browsing"
0 commit comments