Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions modules/browser_object_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,18 @@ def refresh_page(self) -> BasePage:
self.wait_for_page_to_load()
return self

@BasePage.context_chrome
def hard_reload_with_key_combo(self) -> BasePage:
"""
Use Cmd/Ctrl + Shift + R to hard reload the page and overide cache.
"""
if self.sys_platform() == "Darwin":
mod_key = Keys.COMMAND
else:
mod_key = Keys.CONTROL
self.perform_key_combo(mod_key, Keys.SHIFT, "r")
return self

def handle_geolocation_prompt(
self, button_type="primary", remember_this_decision=False
):
Expand Down
58 changes: 58 additions & 0 deletions tests/tabs/test_reload_overiding_cache_keys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import pytest
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver import Firefox
from selenium.webdriver.common.by import By

from modules.browser_object import TabBar
from modules.browser_object_navigation import Navigation


@pytest.fixture()
def test_case():
return "134642"


TEST_URL = "https://postman-echo.com/headers"


def test_reload_overiding_cache_keys(driver: Firefox, sys_platform: str):
"""
C134642 - Verify that tabs can be hard reloaded (overriding cache) using keyboard shortcut CTRL/CMD + SHIFT + R.
"""

browser = TabBar(driver)
nav = Navigation(driver)

# New tab + navigate
browser.new_tab_by_button()
driver.switch_to.window(driver.window_handles[-1])
driver.get(TEST_URL)

# Hard reload using helper function for action CTRL/CMD + SHIFT + "r"
nav.hard_reload_with_key_combo()

# Verify cache is not being used by checking for http request headers
# Header "if-none-match" should not be sent
try:
etag = driver.find_element(By.ID, "/headers/if-none-match").get_attribute(
"innerText"
)
assert False, f"Unexpected If-None-Match present: {etag!r}"
except NoSuchElementException:
pass

# Header "pragma" should be sent with with value "no-cache"
pragma_text = driver.find_element(By.ID, "/headers/pragma").get_attribute(
"innerText"
)
assert "no-cache" in pragma_text, (
f"Expected 'no-cache' in pragma; got: {pragma_text!r}"
)

# Header "cache-control" should be sent with with value "no-cache"
cache_control_text = driver.find_element(
By.ID, "/headers/cache-control"
).get_attribute("innerText")
assert "no-cache" in cache_control_text, (
f"Expected 'no-cache' in cache-control; got: {cache_control_text!r}"
)
Loading