Skip to content

Commit 3155ff4

Browse files
committed
private browsing closing tab not working
1 parent 428a09d commit 3155ff4

File tree

8 files changed

+93
-4
lines changed

8 files changed

+93
-4
lines changed

modules/browser_object_panel_ui.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,12 @@ def start_sync(self) -> BasePage:
132132
self.element_has_text("fxa-sync-label", "Sync now")
133133
self.get_element("fxa-sync-label").click()
134134
return self
135+
136+
def open_private_window(self) -> BasePage:
137+
"""
138+
Opens a new window in private browsing mode using the panel
139+
"""
140+
self.open_panel_menu()
141+
with self.driver.context(self.driver.CONTEXT_CHROME):
142+
self.get_element("panel-ui-new-private-window").click()
143+
return self

modules/browser_object_tabbar.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,12 @@ def get_bar_y():
244244
self.actions.move_by_offset(0, (sign * pixels))
245245
self.actions.release()
246246
self.actions.perform()
247+
248+
def close_tab_of_index(self, index: int) -> BasePage:
249+
"""
250+
Given the index of the tab, it closes that tab.
251+
"""
252+
cur_tab = self.click_tab_by_index(index)
253+
with self.driver.context(self.driver.CONTEXT_CHROME):
254+
self.get_element("tab-x-icon", parent_element=cur_tab).click()
255+
return self

modules/data/navigation.components.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
]
1010
},
1111

12+
"awesome-bar-private": {
13+
"selectorData": "urlbar-input",
14+
"strategy": "id",
15+
"groups": [
16+
"awesomeBar"
17+
]
18+
},
19+
1220
"results-dropdown": {
1321
"selectorData": "urlbar-results",
1422
"strategy": "id",

modules/data/panel_ui.components.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@
107107
"selectorData": "toolbarbutton[class='restoreallitem subviewbutton panel-subview-footer-button']",
108108
"strategy": "css",
109109
"groups": []
110+
},
111+
112+
"panel-ui-new-private-window": {
113+
"selectorData": "appMenu-new-private-window-button2",
114+
"strategy": "id",
115+
"groups": []
110116
}
111117

112118
}

modules/page_object_about_prefs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from modules.classes.autofill_base import AutofillAddressBase
1111
from modules.classes.credit_card import CreditCardBase
1212
from modules.page_base import BasePage
13-
from modules.util import BrowserActions, PomUtils
13+
from modules.util import PomUtils
1414

1515

1616
class AboutPrefs(BasePage):

tests/address_bar_and_search/test_google_search_counts_us.py

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

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

65
from modules.browser_object import Navigation

tests/preferences/test_clear_cookie_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ def open_clear_cookies_data_dialog():
2727

2828
# Check for a non-zero value of the 'Cookies and site data' option
2929
cookie_value = about_prefs.get_clear_cookie_data_value()
30-
assert cookie_value is not 0
30+
assert cookie_value != 0
3131

3232
# Then clear the cookies and site data
3333
about_prefs.get_element("clear-data-accept-button").click()
3434

3535
# Finally, check the value of the dialog option, it should be 0
3636
open_clear_cookies_data_dialog()
3737
cookie_value2 = about_prefs.get_clear_cookie_data_value()
38-
assert cookie_value2 is 0
38+
assert cookie_value2 == 0
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
from time import sleep
2+
3+
import pytest
4+
from selenium.webdriver import Firefox
5+
from selenium.webdriver.common.keys import Keys
6+
7+
from modules.browser_object import Navigation, PanelUi, TabBar
8+
9+
VISIT_URL = "about:about"
10+
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+
24+
@pytest.fixture()
25+
def add_prefs():
26+
return []
27+
28+
29+
def test_undo_close_tab_private_browsing(driver: Firefox):
30+
"""
31+
C120118: ensure that you can close a tab in private browsing window
32+
"""
33+
# instantiate objs
34+
panel_ui = PanelUi(driver)
35+
nav = Navigation(driver).open()
36+
tabs = TabBar(driver)
37+
38+
# open a new private window and open a new tab
39+
panel_ui.open_private_window()
40+
tabs.switch_to_new_tab()
41+
42+
# open a new tab
43+
tabs.new_tab_by_button()
44+
tabs.switch_to_new_tab()
45+
46+
# navigate to the URL NOTE: TEMPORARY GET AWESOME BAR PRIVATE. ADD SUPPORT FOR IT IN NAVIGATION
47+
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)
55+
56+
tabs.close_tab_of_index(0)
57+
58+
sleep(40)

0 commit comments

Comments
 (0)