Skip to content

Commit 88ba17f

Browse files
committed
Test 134642: Created test to verify tabs can be reloaded (overriding cache) by using keyboard shortcuts (Bug 1976547)
1 parent 168c243 commit 88ba17f

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
from selenium.webdriver.common.keys import Keys
6+
7+
from modules.browser_object import TabBar
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+
25+
# New tab + navigate
26+
browser.new_tab_by_button()
27+
driver.switch_to.window(driver.window_handles[-1])
28+
driver.get(TEST_URL)
29+
30+
# Hard reload action sequence hold CTRL/CMD + SHIFT and press "r"
31+
with driver.context(driver.CONTEXT_CHROME):
32+
actions = browser.actions
33+
if sys_platform == "Darwin":
34+
actions.key_down(Keys.COMMAND).key_down(Keys.SHIFT).send_keys("r").key_up(
35+
Keys.SHIFT
36+
).key_up(Keys.COMMAND).perform()
37+
else:
38+
actions.key_down(Keys.CONTROL).key_down(Keys.SHIFT).send_keys("r").key_up(
39+
Keys.SHIFT
40+
).key_up(Keys.CONTROL).perform()
41+
42+
# Verify cache is not being used by checking for http request headers
43+
# Header "if-none-match" should not be sent
44+
try:
45+
etag = driver.find_element(By.ID, "/headers/if-none-match").get_attribute(
46+
"innerText"
47+
)
48+
assert False, f"Unexpected If-None-Match present: {etag!r}"
49+
except NoSuchElementException:
50+
pass
51+
52+
# Header "pragma" should be sent with with value "no-cache"
53+
pragma_text = driver.find_element(By.ID, "/headers/pragma").get_attribute(
54+
"innerText"
55+
)
56+
assert "no-cache" in pragma_text, (
57+
f"Expected 'no-cache' in pragma; got: {pragma_text!r}"
58+
)
59+
60+
# Header "cache-control" should be sent with with value "no-cache"
61+
cache_control_text = driver.find_element(
62+
By.ID, "/headers/cache-control"
63+
).get_attribute("innerText")
64+
assert "no-cache" in cache_control_text, (
65+
f"Expected 'no-cache' in cache-control; got: {cache_control_text!r}"
66+
)

0 commit comments

Comments
 (0)