|
| 1 | +import pytest |
| 2 | +from selenium.common.exceptions import NoSuchElementException |
| 3 | +from selenium.webdriver import Firefox |
| 4 | +from selenium.webdriver.common.by import By |
| 5 | + |
| 6 | +from modules.browser_object import TabBar |
| 7 | +from modules.browser_object_navigation import Navigation |
| 8 | + |
| 9 | + |
| 10 | +@pytest.fixture() |
| 11 | +def test_case(): |
| 12 | + return "134642" |
| 13 | + |
| 14 | + |
| 15 | +TEST_URL = "https://postman-echo.com/headers" |
| 16 | + |
| 17 | + |
| 18 | +def test_reload_overiding_cache_keys(driver: Firefox, sys_platform: str): |
| 19 | + """ |
| 20 | + C134642 - Verify that tabs can be hard reloaded (overriding cache) using keyboard shortcut CTRL/CMD + SHIFT + R. |
| 21 | + """ |
| 22 | + |
| 23 | + browser = TabBar(driver) |
| 24 | + nav = Navigation(driver) |
| 25 | + |
| 26 | + # New tab + navigate |
| 27 | + browser.new_tab_by_button() |
| 28 | + driver.switch_to.window(driver.window_handles[-1]) |
| 29 | + driver.get(TEST_URL) |
| 30 | + |
| 31 | + # Hard reload using helper function for action CTRL/CMD + SHIFT + "r" |
| 32 | + nav.hard_reload_with_key_combo() |
| 33 | + |
| 34 | + # Verify cache is not being used by checking for http request headers |
| 35 | + # Header "if-none-match" should not be sent |
| 36 | + try: |
| 37 | + etag = driver.find_element(By.ID, "/headers/if-none-match").get_attribute( |
| 38 | + "innerText" |
| 39 | + ) |
| 40 | + assert False, f"Unexpected If-None-Match present: {etag!r}" |
| 41 | + except NoSuchElementException: |
| 42 | + pass |
| 43 | + |
| 44 | + # Header "pragma" should be sent with with value "no-cache" |
| 45 | + pragma_text = driver.find_element(By.ID, "/headers/pragma").get_attribute( |
| 46 | + "innerText" |
| 47 | + ) |
| 48 | + assert "no-cache" in pragma_text, ( |
| 49 | + f"Expected 'no-cache' in pragma; got: {pragma_text!r}" |
| 50 | + ) |
| 51 | + |
| 52 | + # Header "cache-control" should be sent with with value "no-cache" |
| 53 | + cache_control_text = driver.find_element( |
| 54 | + By.ID, "/headers/cache-control" |
| 55 | + ).get_attribute("innerText") |
| 56 | + assert "no-cache" in cache_control_text, ( |
| 57 | + f"Expected 'no-cache' in cache-control; got: {cache_control_text!r}" |
| 58 | + ) |
0 commit comments