Skip to content

Commit c346911

Browse files
sv-hyacoubHani YacoubHani YacoubHani Yacoub
authored
Hani/test searchengine result page load on reload or back (#935)
* Test * Test searchengine result page load on reload and back * Add test in manifests * Add wait * format * Edit wait * remove wait * Extend sleep time * Edit * Extend sleep time * minor edits --------- Co-authored-by: Hani Yacoub <hani.yacoub@svadmins-MBP.lan> Co-authored-by: Hani Yacoub <hani.yacoub@svadmins-MacBook-Pro.local> Co-authored-by: Hani Yacoub <hani.yacoub@SL1943-7.softvision.ro>
1 parent 574772e commit c346911

9 files changed

+114
-19
lines changed

SELECTOR_INFO.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3769,9 +3769,9 @@ Location: Bookmark panel
37693769
Path to .json: modules/data/pane_ui.components.json
37703770
```
37713771
```
3772-
Selector Name: toolbar-blank-space
3773-
Selector Data: customizableui-special-spring1
3774-
Description: Blank space in the toolbar
3772+
Selector Name: toolbarspring
3773+
Selector Data: customizableui-special-spring2
3774+
Description: toolbarspring
37753775
Location: Toolbar
37763776
Path to .json: modules/data/navigation.components.json
37773777
```
@@ -4156,13 +4156,6 @@ Description: Ungroup the tab group
41564156
Location: Menu that opens when right click on the tab group label
41574157
Path to .json: modules/data/tab_bar.components.json
41584158
```
4159-
```
4160-
Selector Name: tabgroup-save-and-close-group
4161-
Selector Data: "tabGroupEditor_saveAndCloseGroup"
4162-
Description: Save and close the tab group
4163-
Location: Menu that opens when right click on the tab group label
4164-
Path to .json: modules/data/tab_bar.components.json
4165-
```
41664159
#### text_area_form_autofill
41674160
```
41684161
Selector Name: street-address-textarea

manifests/key.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ address_bar_and_search:
165165
result: pass
166166
splits:
167167
- functional1
168+
test_searchengine_result_page_load_on_reload_or_back:
169+
result: pass
170+
splits:
171+
- functional1
168172
test_searchbar_results_shown_in_a_new_tab:
169173
result: unstable
170174
splits:

modules/browser_object_navigation.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,3 +1232,15 @@ def expect_container_label(self, label_expected: str):
12321232
"""
12331233
actual_label = self.get_element("tab-container-label").text
12341234
assert actual_label == label_expected
1235+
1236+
@BasePage.context_chrome
1237+
def click_back_button(self) -> None:
1238+
"""
1239+
Click the 'Back' button.
1240+
Waits until the button is visible and clickable before performing the click.
1241+
"""
1242+
# Wait until the element is visible and clickable
1243+
self.expect(lambda _: self.get_element("back-button").is_displayed())
1244+
1245+
# Click the button
1246+
self.get_element("back-button").click()

modules/data/navigation.components.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,5 +687,13 @@
687687
"selectorData": "customizableui-special-spring1",
688688
"strategy": "id",
689689
"groups": []
690+
},
691+
692+
"back-button": {
693+
"selectorData": "back-button",
694+
"strategy": "id",
695+
"groups": [
696+
"doNotCache"
697+
]
690698
}
691699
}

modules/page_object_about_pages.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,23 @@ class AboutTelemetry(BasePage):
286286

287287
URL_TEMPLATE = "about:telemetry"
288288

289+
def open_raw_json_data(self):
290+
"""
291+
Opens the Raw JSON telemetry view:
292+
- Click Raw category
293+
- Switch to the new tab
294+
- Click the Raw Data tab
295+
"""
296+
297+
# Click "Raw" category
298+
self.get_element("category-raw").click()
299+
300+
# Switching to the new tab opened by Raw
301+
self.switch_to_new_tab()
302+
303+
# Click "Raw Data" tab
304+
self.get_element("rawdata-tab").click()
305+
289306

290307
class AboutNetworking(BasePage):
291308
"""

tests/address_bar_and_search/test_google_search_counts_us.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ def test_google_search_counts_us(driver: Firefox):
3636

3737
telemetry = AboutTelemetry(driver).open()
3838
sleep(WAIT_TELEMETRY_LOAD)
39-
telemetry.get_element("category-raw").click()
40-
telemetry.switch_to_new_tab()
41-
telemetry.get_element("rawdata-tab").click()
39+
telemetry.open_raw_json_data()
4240

4341
json_data = utils.decode_url(driver)
4442

tests/address_bar_and_search/test_google_withads_url_bar_us.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ def test_google_withads_url_bar_us(driver):
4646

4747
about_telemetry = AboutTelemetry(driver).open()
4848
sleep(5)
49-
about_telemetry.get_element("category-raw").click()
50-
about_telemetry.switch_to_new_tab()
51-
about_telemetry.get_element("rawdata-tab").click()
49+
about_telemetry.open_raw_json_data()
5250

5351
json_data = util.decode_url(driver)
5452
if util.assert_json_value(json_data, path, 1):

tests/address_bar_and_search/test_sap_google_adclick.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ def test_sap_google_adclick(driver: Firefox):
3434

3535
telemetry = AboutTelemetry(driver).open()
3636
sleep(SLEEP_BEFORE_VERIFICATION)
37-
telemetry.get_element("category-raw").click()
38-
telemetry.switch_to_new_tab()
39-
telemetry.get_element("rawdata-tab").click()
37+
telemetry.open_raw_json_data()
4038

4139
json_data = utils.decode_url(driver)
4240
assert utils.assert_json_value(
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from time import sleep
2+
3+
import pytest
4+
from selenium.webdriver import Firefox
5+
6+
from modules.browser_object_navigation import Navigation
7+
from modules.browser_object_tabbar import TabBar
8+
from modules.page_object_about_pages import AboutTelemetry
9+
from modules.util import Utilities
10+
11+
TEXT = "Firefox"
12+
SEARCHBAR_PATH = (
13+
'$..["browser.search.content.searchbar"].["google:tagged:firefox-b-1-d"]'
14+
)
15+
16+
17+
@pytest.fixture()
18+
def test_case():
19+
return "3028909"
20+
21+
22+
def test_searchengine_result_page_load_on_reload_or_back(driver: Firefox):
23+
"""
24+
C3028909 - Search Engine Result Page loads as a result of a reload or a back-button press
25+
"""
26+
27+
# Instantiate objects
28+
nav = Navigation(driver)
29+
telemetry = AboutTelemetry(driver)
30+
utils = Utilities()
31+
tab = TabBar(driver)
32+
33+
# Go to "Customize Toolbar", drag Search bar to Toolbar and click Done
34+
nav.add_search_bar_to_toolbar()
35+
36+
# Using the search bar perform a search
37+
nav.search_bar_search(TEXT)
38+
sleep(5)
39+
40+
# Press back button from the browser menu
41+
nav.click_back_button()
42+
43+
# Go to about:telemetry -> Raw JSON -> Raw data
44+
telemetry.open()
45+
telemetry.open_raw_json_data()
46+
47+
# Verify "browser.search.content.searchbar": { "google:tagged:firefox-b-d": 1}*
48+
json_data = utils.decode_url(driver)
49+
searchbar_ping = utils.assert_json_value(json_data, SEARCHBAR_PATH, 1)
50+
assert searchbar_ping, f"Telemetry path not found: {SEARCHBAR_PATH}"
51+
52+
# Open new tab and perform a new search in the search bar
53+
tab.new_tab_by_button()
54+
nav.search_bar_search(TEXT)
55+
56+
# Press reload button
57+
nav.refresh_page()
58+
59+
# Go back to raw data page and reload it
60+
driver.switch_to.window(driver.window_handles[1])
61+
nav.refresh_page()
62+
telemetry.get_element("rawdata-tab").click()
63+
64+
# Verify "browser.search.content.searchbar": { "google:tagged:firefox-b-d": 2}*
65+
json_data = utils.decode_url(driver)
66+
ping_value = utils.assert_json_value(json_data, SEARCHBAR_PATH, 2)
67+
assert ping_value, f"Telemetry path not found or value mismatch: {SEARCHBAR_PATH}"

0 commit comments

Comments
 (0)