Skip to content

Commit bb2ec01

Browse files
committed
merge changes in
2 parents b4a7097 + 18d5f23 commit bb2ec01

11 files changed

+251
-26
lines changed

modules/browser_object_navigation.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ def get_awesome_bar(self) -> WebElement:
3737
self.set_awesome_bar()
3838
return self.awesome_bar
3939

40+
def get_awesome_bar_text(self):
41+
"""
42+
Get the text directly from the awesome bar.
43+
This is different from 'driver.current_url' which pulls from href
44+
"""
45+
self.set_chrome_context()
46+
awesome_bar = self.get_element("awesome-bar").get_attribute("value")
47+
return awesome_bar
48+
4049
def clear_awesome_bar(self) -> BasePage:
4150
"""Clear the Awesome Bar. Prefer this over get_element("awesome-bar").clear()"""
4251
self.set_awesome_bar()

modules/browser_object_tabbar.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ def expect_tab_sound_status(
106106
)
107107
return self
108108

109+
def expect_title_contains(self, text: str) -> BasePage:
110+
"""
111+
Check if the page title contains given text
112+
"""
113+
self.expect(EC.title_contains(text))
114+
return self
115+
109116
def open_all_tabs_list(self) -> BasePage:
110117
"""Click the Tab Visibility / List All Tabs button"""
111118
with self.driver.context(self.driver.CONTEXT_CHROME):

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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,5 +202,11 @@
202202
"selectorData": "ul[class=\"context-menu-list\"]",
203203
"strategy": "css",
204204
"groups": []
205+
},
206+
207+
"search-result": {
208+
"selectorData": "//div[@data-text-ad]//a",
209+
"strategy": "xpath",
210+
"groups": []
205211
}
206212
}

modules/page_object_about_config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,14 @@ 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
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import time
2+
3+
import pytest
4+
from selenium.webdriver import Firefox
5+
6+
from modules.browser_object import Navigation
7+
from modules.page_object import AboutTelemetry
8+
from modules.page_object_about_config import AboutConfig
9+
from modules.util import Utilities
10+
11+
12+
@pytest.fixture()
13+
def add_prefs():
14+
return [("browser.search.region", "US"), ("cookiebanners.service.mode", 1)]
15+
16+
17+
def test_google_withads_url_bar_us(driver: Firefox):
18+
"""
19+
C1365070, verify that Google withads URL bar - US is recorder into telemetry
20+
"""
21+
22+
# instantiate objects
23+
nav = Navigation(driver).open()
24+
util = Utilities()
25+
26+
nav.search("iphone")
27+
time.sleep(5)
28+
about_telemetry = AboutTelemetry(driver).open()
29+
time.sleep(2)
30+
31+
# Click on Raw JSON, switch tab and click on Raw Data
32+
about_telemetry.get_element("category-raw").click()
33+
about_telemetry.switch_tab()
34+
about_telemetry.get_element("rawdata-tab").click()
35+
36+
# Verify the following ping is recorded: ""browser.search.withads.urlbar": { "google:tagged": 1}".
37+
json_data = util.decode_url(driver)
38+
assert util.assert_json_value(
39+
json_data, '$..["browser.search.withads.urlbar"].["google:tagged"]', 1
40+
)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import logging
2+
import time
3+
4+
import pytest
5+
from selenium.webdriver import Firefox
6+
7+
from modules.browser_object_navigation import Navigation
8+
from modules.page_object_about_config import AboutConfig
9+
from modules.page_object_about_telemetry import AboutTelemetry
10+
from modules.util import Utilities
11+
12+
13+
@pytest.fixture()
14+
def add_prefs():
15+
return [
16+
("browser.search.region", "US"),
17+
]
18+
19+
20+
def test_sap_google_adclick(driver: Firefox):
21+
"""
22+
C1365108, Test SAP Google adclick - URL bar - US
23+
"""
24+
# instantiate objects
25+
nav = Navigation(driver).open()
26+
about_config = AboutConfig(driver)
27+
u = Utilities()
28+
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")
34+
nav.get_element("search-result").click()
35+
time.sleep(2)
36+
37+
# Click on Raw JSON, switch tab and click on Raw Data
38+
about_telemetry = AboutTelemetry(driver).open()
39+
time.sleep(2)
40+
about_telemetry.get_element("category-raw").click()
41+
about_telemetry.switch_tab()
42+
about_telemetry.get_element("rawdata-tab").click()
43+
44+
# Verify pings are recorded
45+
json_data = u.decode_url(driver)
46+
assert u.assert_json_value(
47+
json_data,
48+
'$..keyedScalars.["browser.search.adclicks.urlbar"].["google:tagged"]',
49+
1,
50+
)
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import pytest
22
from selenium.webdriver import Firefox
33
from selenium.webdriver.common.by import By
4-
from selenium.webdriver.support import expected_conditions as EC
54

6-
from modules.browser_object import Navigation
5+
from modules.browser_object import Navigation, TabBar
76
from modules.page_object import AboutConfig
87

98

@@ -14,6 +13,11 @@ def add_prefs():
1413
]
1514

1615

16+
# Set constants
17+
SEARCH_BAR_PREF = "browser.search.widget.inNavBar"
18+
SEARCH_TERM = "saxophone"
19+
20+
1721
def test_search_bar_results(driver: Firefox):
1822
"""
1923
C1365213 - The Search Bar provides valid results for specific search terms
@@ -22,21 +26,19 @@ def test_search_bar_results(driver: Firefox):
2226
# Create objects
2327
nav = Navigation(driver).open()
2428
ac = AboutConfig(driver)
25-
26-
search_term = "saxophone"
29+
tab = TabBar(driver)
2730

2831
# Check Google results from a Search bar search
2932
# First enable search bar via about:config
30-
pref = "browser.search.widget.inNavBar"
31-
ac.toggle_true_false_config(pref)
33+
ac.toggle_true_false_config(SEARCH_BAR_PREF)
3234
nav.clear_awesome_bar()
3335

3436
# Then run search and check the results
35-
nav.search_bar_search(search_term)
37+
nav.search_bar_search(SEARCH_TERM)
3638
nav.set_content_context()
37-
nav.expect_in_content(EC.title_contains("Google Search"))
39+
tab.expect_title_contains("Google Search")
3840
search_url = driver.current_url
39-
assert search_term in search_url
41+
assert SEARCH_TERM in search_url
4042
content_searchbar = nav.find_element(By.NAME, "q")
4143
content_searchbar_text = content_searchbar.get_attribute("value")
42-
assert content_searchbar_text == search_term
44+
assert content_searchbar_text == SEARCH_TERM

tests/address_bar_and_search/test_search_code_google_non_us.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import pytest
22
from selenium.webdriver import Firefox
33
from selenium.webdriver.common.by import By
4-
from selenium.webdriver.support import expected_conditions as ec
54

6-
from modules.browser_object import ContextMenu, Navigation
5+
from modules.browser_object import ContextMenu, Navigation, TabBar
76
from modules.page_object import AboutConfig
87

98

@@ -15,6 +14,11 @@ def add_prefs():
1514
]
1615

1716

17+
# Set constants
18+
FX_SEARCH_CODE = "client=firefox-b-d"
19+
SEARCH_BAR_PREF = "browser.search.widget.inNavBar"
20+
21+
1822
def test_search_code_google_us(driver: Firefox):
1923
"""
2024
C1365269 - Default Search Code: Google - non-US
@@ -26,29 +30,28 @@ def test_search_code_google_us(driver: Firefox):
2630
nav = Navigation(driver).open()
2731
ac = AboutConfig(driver)
2832
context_menu = ContextMenu(driver)
33+
tab = TabBar(driver)
2934

3035
def search_code_assert():
3136
# Function to check the search code of a Google search in US region
32-
fx_code = "client=firefox-b-d"
3337
nav.set_content_context()
3438
search_url = driver.current_url
35-
assert fx_code in search_url
39+
assert FX_SEARCH_CODE in search_url
3640
nav.clear_awesome_bar()
3741

3842
# Check code generated from the Awesome bar search
3943
nav.search("soccer")
40-
nav.expect(ec.title_contains("Google Search"))
44+
tab.expect_title_contains("Google Search")
4145
search_code_assert()
4246

4347
# Check code generated from the Search bar search
4448
# First enable search bar via about:config
45-
pref = "browser.search.widget.inNavBar"
46-
ac.toggle_true_false_config(pref)
49+
ac.toggle_true_false_config(SEARCH_BAR_PREF)
4750
nav.clear_awesome_bar()
4851

4952
# Then run the code check
5053
nav.search_bar_search("soccer")
51-
nav.expect(ec.title_contains("Google Search"))
54+
tab.expect_title_contains("Google Search")
5255
search_code_assert()
5356

5457
# Check code generated from the context click of selected text
@@ -64,5 +67,5 @@ def search_code_assert():
6467
# Switch to the newly opened tab and run the code check
6568
window_handles = driver.window_handles
6669
driver.switch_to.window(window_handles[-1])
67-
nav.expect(ec.title_contains("Google Search"))
70+
tab.expect_title_contains("Google Search")
6871
search_code_assert()

tests/address_bar_and_search/test_search_code_google_us.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from selenium.webdriver.common.by import By
44
from selenium.webdriver.support import expected_conditions as EC
55

6-
from modules.browser_object import ContextMenu, Navigation
6+
from modules.browser_object import ContextMenu, Navigation, TabBar
77
from modules.page_object import AboutConfig
88

99

@@ -15,6 +15,11 @@ def add_prefs():
1515
]
1616

1717

18+
# Set constant
19+
FX_SEARCH_CODE = "client=firefox-b-1-d"
20+
SEARCH_BAR_PREF = "browser.search.widget.inNavBar"
21+
22+
1823
def test_search_code_google_us(driver: Firefox):
1924
"""
2025
C1365268 - Default Search Code: Google - US
@@ -26,13 +31,13 @@ def test_search_code_google_us(driver: Firefox):
2631
nav = Navigation(driver).open()
2732
ac = AboutConfig(driver)
2833
context_menu = ContextMenu(driver)
34+
tab = TabBar(driver)
2935

3036
def search_code_assert():
3137
# Function to check the search code of a Google search in US region
32-
fx_code = "client=firefox-b-1-d"
3338
nav.set_content_context()
3439
search_url = driver.current_url
35-
assert fx_code in search_url
40+
assert FX_SEARCH_CODE in search_url
3641
nav.clear_awesome_bar()
3742

3843
# Check code generated from the Awesome bar search
@@ -42,13 +47,12 @@ def search_code_assert():
4247

4348
# Check code generated from the Search bar search
4449
# First enable search bar via about:config
45-
pref = "browser.search.widget.inNavBar"
46-
ac.toggle_true_false_config(pref)
50+
ac.toggle_true_false_config(SEARCH_BAR_PREF)
4751
nav.clear_awesome_bar()
4852

4953
# Then run the code check
5054
nav.search_bar_search("soccer")
51-
nav.expect(EC.title_contains("Google Search"))
55+
tab.expect_title_contains("Google Search")
5256
search_code_assert()
5357

5458
# Check code generated from the context click of selected text
@@ -64,5 +68,5 @@ def search_code_assert():
6468
# Switch to the newly opened tab and run the code check
6569
window_handles = driver.window_handles
6670
driver.switch_to.window(window_handles[-1])
67-
nav.expect(EC.title_contains("Google Search"))
71+
tab.expect_title_contains("Google Search")
6872
search_code_assert()

0 commit comments

Comments
 (0)