Skip to content

Commit 3ae2f66

Browse files
committed
Created a helper fucntion for hard reload in the Navigation class and used it in test to verify cache overiding
1 parent 73c8008 commit 3ae2f66

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
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
):

tests/tabs/test_reload_overiding_cache_keys.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
from selenium.common.exceptions import NoSuchElementException
33
from selenium.webdriver import Firefox
44
from selenium.webdriver.common.by import By
5-
from selenium.webdriver.common.keys import Keys
65

76
from modules.browser_object import TabBar
7+
from modules.browser_object_navigation import Navigation
88

99

1010
@pytest.fixture()
@@ -21,23 +21,15 @@ def test_reload_overiding_cache_keys(driver: Firefox, sys_platform: str):
2121
"""
2222

2323
browser = TabBar(driver)
24+
nav = Navigation(driver)
2425

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

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()
31+
# Hard reload using helper function for action CTRL/CMD + SHIFT + "r"
32+
nav.hard_reload_with_key_combo()
4133

4234
# Verify cache is not being used by checking for http request headers
4335
# Header "if-none-match" should not be sent

0 commit comments

Comments
 (0)