Skip to content

Commit 50755a1

Browse files
Hani YacoubHani Yacoub
authored andcommitted
Funtion to change pref value in order to dismiss accept cookies page
1 parent 30134e4 commit 50755a1

File tree

4 files changed

+31
-10
lines changed

4 files changed

+31
-10
lines changed

modules/data/about_config.components.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,17 @@
1111
"selectorData": "about-config-search",
1212
"strategy": "id",
1313
"groups": []
14+
},
15+
16+
"cell-edit": {
17+
"selectorData": "cell-edit",
18+
"strategy": "class",
19+
"groups": []
20+
},
21+
22+
"form-edit": {
23+
"selectorData": "//input[@aria-label='cookiebanners.service.mode']",
24+
"strategy": "xpath",
25+
"groups": []
1426
}
1527
}

modules/data/navigation.components.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,6 @@
148148
]
149149
},
150150

151-
"accept-cookies": {
152-
"selectorData": "L2AGLb",
153-
"strategy": "id",
154-
"groups": []
155-
},
156-
157151
"search-result": {
158152
"selectorData": "//div[@data-text-ad]//a",
159153
"strategy": "xpath",

modules/page_object_about_config.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,15 @@ def toggle_true_false_config(self, term: str) -> BasePage:
3838
self.search_pref(term)
3939
self.toggle_true_false()
4040
return self
41+
42+
def change_pref_value(self, term: str, value) -> BasePage:
43+
self.set_content_context()
44+
self.driver.get("about:config")
45+
self.search_pref(term)
46+
pref_edit_button = self.get_element("cell-edit")
47+
pref_edit_button.click()
48+
pref_edit = self.get_element("form-edit")
49+
pref_edit.send_keys(value)
50+
pref_edit_button.click()
51+
return self
52+

tests/address_bar_and_search/test_sap_google_adclick.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from selenium.webdriver import Firefox
55

66
from modules.browser_object_navigation import Navigation
7+
from modules.page_object_about_config import AboutConfig
78

89
from modules.page_object_about_telemetry import AboutTelemetry
910
from modules.util import Utilities
@@ -22,12 +23,14 @@ def test_sap_google_adclick(driver: Firefox):
2223
"""
2324
# instantiate objects
2425
nav = Navigation(driver).open()
25-
nav.search("iphone")
26-
time.sleep(2)
26+
about_config = AboutConfig(driver)
2727
u = Utilities()
2828

29-
# click on any ad
30-
nav.get_element("accept-cookies").click()
29+
# change pref value in order to not display accept cookies banner
30+
about_config.change_pref_value("cookiebanners.service.mode", 1)
31+
32+
# search and click on an ad
33+
nav.search("iphone")
3134
nav.get_element("search-result").click()
3235
time.sleep(2)
3336

0 commit comments

Comments
 (0)