Skip to content

Commit 197810d

Browse files
committed
mrege changes in
2 parents 12e7a3e + 3436c31 commit 197810d

File tree

6 files changed

+101
-8
lines changed

6 files changed

+101
-8
lines changed

modules/data/about_prefs.components.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,18 @@
240240
"groups": []
241241
},
242242

243+
"cookies-manage-data": {
244+
"selectorData": "siteDataSettings",
245+
"strategy": "id",
246+
"groups": []
247+
},
248+
249+
"cookies-manage-data-sitelist": {
250+
"selectorData": "sitesList",
251+
"strategy": "id",
252+
"groups": []
253+
},
254+
243255
"tracking-checkbox": {
244256
"selectorData": "contentBlockingTrackingProtectionCheckbox",
245257
"strategy": "id",

modules/data/generic_page.components.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@
2323
"groups": []
2424
},
2525

26+
"wiki-search-bar": {
27+
"selectorData": "searchInput",
28+
"strategy": "id",
29+
"groups": []
30+
},
31+
32+
"wiki-search-button": {
33+
"selectorData": "button[class='cdx-button cdx-button--action-default cdx-button--weight-normal cdx-button--size-medium cdx-button--framed cdx-search-input__end-button']",
34+
"strategy": "css",
35+
"groups": []
36+
},
37+
2638
"simulated-tracker-block-status": {
2739
"selectorData": "blacklisted-blocked",
2840
"strategy": "id",

modules/data/login_autofill.components.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,23 @@
2929
"groups": [
3030
"doNotCache"
3131
]
32+
},
33+
34+
"username-login-field": {
35+
"selectorData": "/html/body/div[1]/form[2]/input[1]",
36+
"strategy": "xpath",
37+
"groups": []
38+
},
39+
40+
"password-login-field": {
41+
"selectorData": "/html/body/div[1]/form[2]/input[2]",
42+
"strategy": "xpath",
43+
"groups": []
44+
},
45+
46+
"submit-button-login": {
47+
"selectorData": "/html/body/div[1]/form[2]/input[3]",
48+
"strategy": "xpath",
49+
"groups": []
3250
}
3351
}

modules/page_base.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,19 @@ def get_all_children(
541541
children = element.find_elements(By.XPATH, "./*")
542542
return children
543543

544+
def wait_for_no_children(
545+
self, parent: Union[str, tuple, WebElement], labels=[]
546+
) -> Page:
547+
"""
548+
Waits for 0 children under the given parent, the wait is instant (note, this changes the driver implicit wait and changes it back)
549+
"""
550+
driver_wait = self.driver.timeouts.implicit_wait
551+
self.driver.implicitly_wait(0)
552+
try:
553+
assert len(self.get_all_children(self.fetch(parent, labels))) == 0
554+
finally:
555+
self.driver.implicitly_wait(driver_wait)
556+
544557
def wait_for_num_tabs(self, num_tabs: int) -> Page:
545558
"""
546559
Waits for the driver.window_handles to be updated accordingly with the number of tabs requested

modules/page_object_autofill_login.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,15 @@ def __init__(self, parent: "LoginAutofill") -> None:
2121

2222
def fill_username(self, username: str) -> None:
2323
if self.username_field is None:
24-
username_fields = self.parent.get_elements("username-field")
25-
self.username_field = username_fields[1]
24+
self.username_field = self.parent.get_element("username-login-field")
2625
self.username_field.send_keys(username)
2726

2827
def fill_password(self, password: str) -> None:
2928
if self.password_field is None:
30-
password_fields = self.parent.get_elements(
31-
"input-field", labels=["current-password"]
32-
)
33-
self.password_field = password_fields[0]
29+
self.password_field = self.parent.get_element("password-login-field")
3430
self.password_field.send_keys(password)
3531

3632
def submit(self) -> None:
3733
if self.submit_button is None:
38-
submit_buttons = self.parent.get_elements("submit-form")
39-
self.submit_button = submit_buttons[0]
34+
self.submit_button = self.parent.get_element("submit-button-login")
4035
self.submit_button.click()
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from selenium.webdriver import Firefox
2+
3+
from modules.browser_object import Navigation, PanelUi
4+
from modules.page_object import AboutPrefs, GenericPage
5+
from modules.util import BrowserActions
6+
7+
8+
def test_cookies_not_saved_private_browsing(driver: Firefox):
9+
"""
10+
C101677: ensure that cookies are not saved after using private browsing
11+
"""
12+
# instantiate objs
13+
about_prefs = AboutPrefs(driver, category="privacy")
14+
panel_ui = PanelUi(driver).open()
15+
nav = Navigation(driver)
16+
wiki_page = GenericPage(
17+
driver, url="https://ro.wikipedia.org/wiki/Pagina_principal%C4%83"
18+
)
19+
ba = BrowserActions(driver)
20+
21+
# open new private window
22+
panel_ui.open_private_window()
23+
nav.switch_to_new_window()
24+
25+
# open the wiki page and perform a search
26+
wiki_page.open()
27+
wiki_search_bar = wiki_page.get_element("wiki-search-bar")
28+
wiki_search_bar.send_keys("hello")
29+
wiki_page.get_element("wiki-search-button").click()
30+
wiki_page.wait_for_page_to_load()
31+
32+
# close the page and switch to first tab
33+
driver.close()
34+
driver.switch_to.window(driver.window_handles[0])
35+
about_prefs.open()
36+
37+
# get the cookies
38+
about_prefs.get_element("cookies-manage-data").click()
39+
iframe = about_prefs.get_iframe()
40+
ba.switch_to_iframe_context(iframe)
41+
42+
# wait for no children listed in the cookies menu
43+
about_prefs.wait_for_no_children("cookies-manage-data-sitelist")

0 commit comments

Comments
 (0)