Skip to content

Commit 8035dbb

Browse files
committed
Add test to verify page reloads correctly
1 parent f6c020b commit 8035dbb

File tree

2 files changed

+73
-1
lines changed

2 files changed

+73
-1
lines changed

l10n_CM/run_l10n.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"yellowkorner",
6363
"zalando",
6464
"zara",
65-
"zooplus"
65+
"zooplus",
6666
}
6767

6868
loaded_valid_sites = valid_l10n_mappings().keys()
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import platform
2+
3+
import pytest
4+
from selenium.webdriver import Firefox
5+
from selenium.webdriver.common.by import By
6+
from selenium.webdriver.common.keys import Keys
7+
from selenium.webdriver.support import expected_conditions as EC
8+
from selenium.webdriver.support.ui import WebDriverWait
9+
10+
from modules.browser_object_navigation import Navigation
11+
from modules.page_object_generics import GenericPage
12+
from modules.util import BrowserActions
13+
14+
15+
@pytest.fixture()
16+
def test_case():
17+
return "134720"
18+
19+
20+
def test_reload_tab_via_keyboard(driver: Firefox, sys_platform: str):
21+
"""
22+
C134720 - Verify F5 & Ctrl/Cmd+R will reload tab and clear the search field
23+
"""
24+
25+
test_url = "https://www.wikipedia.org/"
26+
test_text = "test"
27+
search_field_id = "searchInput"
28+
29+
mod_key = Keys.COMMAND if platform.system() == "Darwin" else Keys.CONTROL
30+
31+
# Open up Wikipedia Page
32+
page = GenericPage(driver, url=test_url).open()
33+
ba = BrowserActions(driver)
34+
wait = WebDriverWait(driver, 10)
35+
nav = Navigation(driver)
36+
37+
# Type "test" into the search field
38+
search_field = wait.until(
39+
EC.visibility_of_element_located((By.ID, search_field_id))
40+
)
41+
search_field.click()
42+
ba.clear_and_fill(search_field, test_text, press_enter=False)
43+
assert search_field.get_attribute("value") == test_text
44+
45+
# Perform Ctrl/Cmd+R from chrome context
46+
with driver.context(driver.CONTEXT_CHROME):
47+
nav.click_on("navigation-background-component")
48+
page.perform_key_combo(mod_key, "r")
49+
50+
# Ensure page has reloaded and verify search field is empty
51+
wait.until(EC.staleness_of(search_field))
52+
search_field = wait.until(
53+
EC.visibility_of_element_located((By.ID, search_field_id))
54+
)
55+
assert search_field.get_attribute("value") == ""
56+
57+
# Type "test" into the search field again
58+
search_field.click()
59+
ba.clear_and_fill(search_field, test_text, press_enter=False)
60+
assert search_field.get_attribute("value") == test_text
61+
62+
# Perform F5 from chrome context
63+
with driver.context(driver.CONTEXT_CHROME):
64+
nav.click_on("navigation-background-component")
65+
page.perform_key_combo(Keys.F5)
66+
67+
# Ensure page has reloaded and verify search field is empty
68+
wait.until(EC.staleness_of(search_field)) # ensure page reloaded
69+
search_field = wait.until(
70+
EC.visibility_of_element_located((By.ID, search_field_id))
71+
)
72+
assert search_field.get_attribute("value") == ""

0 commit comments

Comments
 (0)