|
| 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