Skip to content

Commit 6a18302

Browse files
Merge pull request #445 from mozilla/philimon/suite_refactor
Philimon/suite refactor
2 parents e2a409d + 923f05c commit 6a18302

24 files changed

+764
-536
lines changed

SELECTOR_INFO.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Path to .json: (ie, modules/data/google_search.components.json
1212
```
1313
Selector Name: sidebar-options
1414
Selector Data: "button.category[name='{name}']"
15-
Description: Selects an option in about:addons (sidebar)
15+
Description: Selects an option in about:addons(sidebar)
1616
Location: Left side of about:addons page
1717
Path to .json: modules/data/about_addons.components.json
1818
```
@@ -977,6 +977,20 @@ Location: about:preferences#privacy in Exceptions - Saved Passwords modal
977977
Path to .json: modules/data/about_prefs.components.json
978978
```
979979
```
980+
Selector Name: actions-menu
981+
Selector Data: "richlistitem[type='{.*}'] menulist.actionsMenu"
982+
Description: Select Application list that handles how downloads are handled
983+
Location: about:preferences#general Applications subsection
984+
Path to .json: modules/data/about_prefs.components.json
985+
```
986+
```
987+
Selector Name: actions-menu-option
988+
Selector Data: "richlistitem[type='{.*}'] menuitem[label='{.*}']"
989+
Description: Select download option from Application List
990+
Location: about:preferences#general Applications subsection
991+
Path to .json: modules/data/about_prefs.components.json
992+
```
993+
```
980994
Selector Name: use-primary-password
981995
Selector Data: "useMasterPassword"
982996
Description: Checkbox for using primary password
@@ -2156,6 +2170,13 @@ Location: any element that supports the attribute (usually text)
21562170
Path to .json: modules/data/generic_pdf.components.json
21572171
```
21582172
```
2173+
Selector Name: pdf-text-layer
2174+
Selector Data: "textLayer"
2175+
Description: first instance of a text span.
2176+
Location: any element that supports the attribute (usually text)
2177+
Path to .json: modules/data/generic_pdf.components.json
2178+
```
2179+
```
21592180
Selector Name: html-body
21602181
Selector Data: "html"
21612182
Description: The html tag of the pdf
Lines changed: 61 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
import logging
33

4+
from selenium.webdriver import Firefox
45
from selenium.webdriver.common.keys import Keys
56
from selenium.webdriver.support import expected_conditions as EC
67

@@ -11,79 +12,93 @@
1112
class FindToolbar(BasePage):
1213
URL_TEMPLATE = ""
1314

15+
def __init__(self, driver: Firefox, **kwargs):
16+
super().__init__(driver, **kwargs)
17+
self.panel_ui = PanelUi(self.driver)
18+
self.match_dict = {}
19+
20+
@BasePage.context_chrome
1421
def open(self) -> BasePage:
1522
"""Use PanelUi to open the Find Toolbar, wait for element to load"""
16-
panel_ui = PanelUi(self.driver)
17-
with self.driver.context(self.driver.CONTEXT_CHROME):
18-
panel_ui.open_panel_menu()
19-
panel_ui.select_panel_setting("find-in-page")
20-
self.wait_for_page_to_load()
23+
self.panel_ui.open_panel_menu()
24+
self.panel_ui.select_panel_setting("find-in-page")
25+
self.wait_for_page_to_load()
2126
return self
2227

28+
@BasePage.context_chrome
2329
def open_with_key_combo(self) -> BasePage:
2430
"""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()
31+
if self.sys_platform() == "Darwin":
32+
mod_key = Keys.COMMAND
33+
else:
34+
mod_key = Keys.CONTROL
35+
self.perform_key_combo(mod_key, "f")
36+
self.wait_for_page_to_load()
3237
return self
3338

39+
@BasePage.context_chrome
3440
def find(self, term: str) -> BasePage:
3541
"""Use the Find Toolbar to search"""
36-
with self.driver.context(self.driver.CONTEXT_CHROME):
37-
findbar = self.get_element("find-toolbar-input")
38-
findbar.click()
39-
findbar.clear()
40-
findbar.send_keys(term + Keys.ENTER)
42+
find_bar = self.get_element("find-toolbar-input")
43+
find_bar.click()
44+
find_bar.clear()
45+
find_bar.send_keys(term + Keys.ENTER)
46+
if find_bar.get_property("status") != "notfound":
47+
self.match_dict = self.get_match_args()
4148
return self
4249

50+
@BasePage.context_chrome
4351
def get_match_args(self) -> dict:
4452
"""Return the status of the find session"""
45-
with self.driver.context(self.driver.CONTEXT_CHROME):
46-
matches = self.get_element("matches-label")
47-
self.expect(
48-
EC.text_to_be_present_in_element_attribute(
49-
self.get_selector("matches-label"), "data-l10n-args", ":"
50-
)
53+
self.expect(
54+
EC.text_to_be_present_in_element_attribute(
55+
self.get_selector("matches-label"), "data-l10n-args", ":"
5156
)
52-
logging.info(matches.get_attribute("outerHTML"))
53-
match_status_str = matches.get_attribute("data-l10n-args")
54-
return json.loads(match_status_str)
57+
)
58+
matches = self.get_element("matches-label")
59+
logging.info(matches.get_attribute("outerHTML"))
60+
match_status_str = matches.get_attribute("data-l10n-args")
61+
self.match_dict = json.loads(match_status_str)
62+
return self.match_dict
5563

64+
@BasePage.context_chrome
5665
def next_match(self) -> BasePage:
5766
"""Click the Next Match button"""
58-
with self.driver.context(self.driver.CONTEXT_CHROME):
59-
self.get_element("next-match-button").click()
67+
self.get_element("next-match-button").click()
68+
if self.match_dict["current"] < self.match_dict["total"]:
69+
self.match_dict["current"] += 1
70+
else:
71+
self.match_dict["current"] = 1
6072
return self
6173

74+
@BasePage.context_chrome
6275
def previous_match(self) -> BasePage:
6376
"""Click the Previous Match button"""
64-
with self.driver.context(self.driver.CONTEXT_CHROME):
65-
self.get_element("previous-match-button").click()
77+
self.get_element("previous-match-button").click()
78+
if self.match_dict["current"] > 1:
79+
self.match_dict["current"] -= 1
80+
else:
81+
self.match_dict["current"] = self.match_dict["total"]
6682
return self
6783

84+
@BasePage.context_chrome
6885
def rewind_to_first_match(self) -> BasePage:
6986
"""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"]
87+
while self.match_dict["current"] != 1:
88+
self.previous_match()
7989
return self
8090

91+
@BasePage.context_chrome
8192
def navigate_matches_by_keys(self, backwards=False) -> BasePage:
8293
"""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
94+
if backwards:
95+
self.perform_key_combo(Keys.SHIFT, Keys.F3)
96+
else:
97+
logging.info(f"sending {Keys.F3.encode()}")
98+
self.actions.send_keys(Keys.F3).perform()
99+
return self
100+
101+
@BasePage.context_chrome
102+
def navigate_matches_n_times(self, n: int):
103+
for _ in range(n):
104+
self.next_match()

0 commit comments

Comments
 (0)