Skip to content

Commit c7ebe87

Browse files
committed
merge changes in
2 parents f187bb3 + f95867a commit c7ebe87

19 files changed

+346
-5
lines changed

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ requests = "*"
1313
pytest-xdist = "*"
1414
pytest-html = "*"
1515
pypom = "*"
16+
jsonpath-ng = "*"
1617
pillow = "*"
1718

1819
[dev-packages]

ci_pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ markers = [
77
"pynput: test uses pynput package",
88
"incident: incident smoke tests",
99
"unstable: temporary mark for unstable tests",
10+
"slow: test is clocked at more than 30s on modern machines",
1011
"ci: basic tests to run in ci",
1112
"locale_de: tests run in DE locale versions",
1213
"locale_fr: tests run in FR locale versions",

conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,8 @@ def version(driver: webdriver.Firefox):
214214
@pytest.fixture(scope="session", autouse=True)
215215
def faker_seed():
216216
return 19980331
217+
218+
219+
@pytest.fixture(scope="session")
220+
def fillable_pdf_url():
221+
return "https://www.uscis.gov/sites/default/files/document/forms/i-9.pdf"

dev_pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ markers = [
88
"pynput: test uses pynput package",
99
"incident: incident smoke tests",
1010
"unstable: temporary mark for unstable tests",
11+
"slow: test is clocked at more than 30s on modern machines",
1112
"ci: basic tests to run in ci",
1213
"locale_de: tests run in DE locale versions",
1314
"locale_fr: tests run in FR locale versions",

modules/browser_object_find_toolbar.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ def open(self) -> BasePage:
2020
self.wait_for_page_to_load()
2121
return self
2222

23+
def open_with_key_combo(self) -> BasePage:
24+
"""Use Cmd/Ctrl + F to open the Find Toolbar, wait for load"""
25+
with self.driver.context(self.driver.CONTEXT_CHROME):
26+
if self.sys_platform() == "Darwin":
27+
mod_key = Keys.COMMAND
28+
else:
29+
mod_key = Keys.CONTROL
30+
self.perform_key_combo(mod_key, "f")
31+
self.wait_for_page_to_load()
32+
return self
33+
2334
def find(self, term: str) -> BasePage:
2435
"""Use the Find Toolbar to search"""
2536
with self.driver.context(self.driver.CONTEXT_CHROME):
@@ -46,8 +57,33 @@ def next_match(self) -> BasePage:
4657
"""Click the Next Match button"""
4758
with self.driver.context(self.driver.CONTEXT_CHROME):
4859
self.get_element("next-match-button").click()
60+
return self
4961

5062
def previous_match(self) -> BasePage:
5163
"""Click the Previous Match button"""
5264
with self.driver.context(self.driver.CONTEXT_CHROME):
5365
self.get_element("previous-match-button").click()
66+
return self
67+
68+
def rewind_to_first_match(self) -> BasePage:
69+
"""Go back to match 1 of n"""
70+
with self.driver.context(self.driver.CONTEXT_CHROME):
71+
position = self.get_match_args()["current"]
72+
total = self.get_match_args()["total"]
73+
while position != 1:
74+
if position < total // 2:
75+
self.previous_match()
76+
else:
77+
self.next_match()
78+
position = self.get_match_args()["current"]
79+
return self
80+
81+
def navigate_matches_by_keys(self, backwards=False) -> BasePage:
82+
"""Use F3 and Shift+F3 to navigate matches"""
83+
with self.driver.context(self.driver.CONTEXT_CHROME):
84+
if backwards:
85+
self.perform_key_combo(Keys.SHIFT, Keys.F3)
86+
else:
87+
logging.info(f"sending {Keys.F3.encode()}")
88+
self.actions.send_keys(Keys.F3).perform()
89+
return self
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"category-raw": {
3+
"selectorData": "category-raw",
4+
"strategy": "id",
5+
"groups": []
6+
},
7+
8+
"rawdata-tab": {
9+
"selectorData": "//li[@class='tabs-menu-item rawdata ']//a[@id='rawdata-tab']",
10+
"strategy": "xpath",
11+
"groups": []
12+
}
13+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"text-layer": {
3+
"selectorData": "textLayer",
4+
"strategy": "class",
5+
"groups": [
6+
"requiredForPage"
7+
]
8+
},
9+
10+
"highlighted-text": {
11+
"selectorData": ".textLayer .highlight.selected.appended",
12+
"strategy": "css",
13+
"groups": [
14+
"doNotCache"
15+
]
16+
}
17+
}

modules/data/navigation.components.json

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
]
1010
},
1111

12+
"results-dropdown": {
13+
"selectorData": "urlbar-results",
14+
"strategy": "id",
15+
"groups": [
16+
"doNotCache"
17+
]
18+
},
19+
1220
"tab-to-search-text-span": {
1321
"selectorData": "urlbarView-dynamic-onboardTabToSearch-text-container",
1422
"strategy": "class",
@@ -115,7 +123,7 @@
115123
"groups": []
116124
},
117125

118-
126+
119127
"add-extra-search-engine": {
120128
"selectorData": "[id*=urlbar-engine-one-off-item-engine--1][tooltiptext*='{0}']",
121129
"strategy": "css",
@@ -138,6 +146,19 @@
138146
"selectorData": "urlbar-results",
139147
"strategy": "id",
140148
"groups": []
141-
}
149+
},
142150

151+
"addon-suggestion": {
152+
"selectorData": "div.urlbarView-row[type='rust_amo'] span.urlbarView-title.urlbarView-overflowable",
153+
"strategy": "css",
154+
"groups": []
155+
},
156+
157+
"search-suggestion-list": {
158+
"selectorData": "div.urlbarView-row[type='search_engine'] span.urlbarView-title",
159+
"strategy": "css",
160+
"groups": [
161+
"doNotCache"
162+
]
163+
}
143164
}

modules/page_base.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,14 @@ def get_elements(self, name: str, labels=[]):
306306
"""
307307
return self.get_element(name, multiple=True, labels=labels)
308308

309+
def get_parent_of(self, name: str, labels=[]) -> WebElement:
310+
"""
311+
Given a name (and labels if needed), return the direct parent node of the element.
312+
"""
313+
314+
child = self.get_element(name, labels=labels)
315+
return child.find_element(By.XPATH, "..")
316+
309317
def element_exists(self, name: str, labels=[]) -> Page:
310318
"""Expect helper: wait until element exists or timeout"""
311319
self.expect(
@@ -345,6 +353,15 @@ def element_selected(self, name: str, labels=[]) -> Page:
345353
)
346354
return self
347355

356+
def element_has_text(self, name: str, text: str, labels=[]) -> Page:
357+
"""Expect helper: wait until element has given text"""
358+
self.expect(
359+
EC.text_to_be_present_in_element(
360+
self.get_selector(name, labels=labels), text
361+
)
362+
)
363+
return self
364+
348365
def url_contains(self, url_part: str) -> Page:
349366
"""Expect helper: wait until driver URL contains given text or timeout"""
350367
self.expect(EC.url_contains(url_part))
@@ -482,3 +499,8 @@ def loaded(self):
482499
pass
483500
self.set_content_context()
484501
return _loaded
502+
503+
def switch_tab(self):
504+
"""Get list of all window handles, switch to the newly opened tab"""
505+
handles = self.driver.window_handles
506+
self.driver.switch_to.window(handles[-1])

modules/page_object.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
from modules.page_object_about_newtab import *
66
from modules.page_object_about_prefs import *
77
from modules.page_object_about_profiles import *
8+
from modules.page_object_about_telemetry import *
89
from modules.page_object_addons_mozilla_org import *
910
from modules.page_object_autofill_credit_card import *
1011
from modules.page_object_autofill_test_basic import *
1112
from modules.page_object_example_page import *
13+
from modules.page_object_generic_pdf import *
1214
from modules.page_object_google_search import *
1315
from modules.page_object_wiki_firefox_logo import *

0 commit comments

Comments
 (0)