Skip to content

Commit 855f981

Browse files
authored
Merge pull request #779 from ruhankiani/test/test_reload_overiding_cache_keys
Test 134642: Created test to verify tabs can be reloaded (overriding cache) by using keyboard shortcuts (Bug 1976547)
2 parents 4ae069d + 3ae2f66 commit 855f981

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

modules/browser_object_navigation.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,18 @@ def refresh_page(self) -> BasePage:
307307
self.wait_for_page_to_load()
308308
return self
309309

310+
@BasePage.context_chrome
311+
def hard_reload_with_key_combo(self) -> BasePage:
312+
"""
313+
Use Cmd/Ctrl + Shift + R to hard reload the page and overide cache.
314+
"""
315+
if self.sys_platform() == "Darwin":
316+
mod_key = Keys.COMMAND
317+
else:
318+
mod_key = Keys.CONTROL
319+
self.perform_key_combo(mod_key, Keys.SHIFT, "r")
320+
return self
321+
310322
def handle_geolocation_prompt(
311323
self, button_type="primary", remember_this_decision=False
312324
):
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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

Comments
 (0)