Skip to content

Commit edd46e2

Browse files
renamed context switch decorators
1 parent de8ea7c commit edd46e2

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

modules/browser_object_find_toolbar.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ def __init__(self, driver: Firefox, **kwargs):
1717
self.panel_ui = PanelUi(self.driver)
1818
self.match_dict = {}
1919

20-
@BasePage.chrome_context
20+
@BasePage.context_chrome
2121
def open(self) -> BasePage:
2222
"""Use PanelUi to open the Find Toolbar, wait for element to load"""
2323
self.panel_ui.open_panel_menu()
2424
self.panel_ui.select_panel_setting("find-in-page")
2525
self.wait_for_page_to_load()
2626
return self
2727

28-
@BasePage.chrome_context
28+
@BasePage.context_chrome
2929
def open_with_key_combo(self) -> BasePage:
3030
"""Use Cmd/Ctrl + F to open the Find Toolbar, wait for load"""
3131
if self.sys_platform() == "Darwin":
@@ -36,7 +36,7 @@ def open_with_key_combo(self) -> BasePage:
3636
self.wait_for_page_to_load()
3737
return self
3838

39-
@BasePage.chrome_context
39+
@BasePage.context_chrome
4040
def find(self, term: str) -> BasePage:
4141
"""Use the Find Toolbar to search"""
4242
find_bar = self.get_element("find-toolbar-input")
@@ -47,7 +47,7 @@ def find(self, term: str) -> BasePage:
4747
self.match_dict = self.get_match_args()
4848
return self
4949

50-
@BasePage.chrome_context
50+
@BasePage.context_chrome
5151
def get_match_args(self) -> dict:
5252
"""Return the status of the find session"""
5353
self.expect(
@@ -61,7 +61,7 @@ def get_match_args(self) -> dict:
6161
self.match_dict = json.loads(match_status_str)
6262
return self.match_dict
6363

64-
@BasePage.chrome_context
64+
@BasePage.context_chrome
6565
def next_match(self) -> BasePage:
6666
"""Click the Next Match button"""
6767
self.get_element("next-match-button").click()
@@ -71,7 +71,7 @@ def next_match(self) -> BasePage:
7171
self.match_dict["current"] = 1
7272
return self
7373

74-
@BasePage.chrome_context
74+
@BasePage.context_chrome
7575
def previous_match(self) -> BasePage:
7676
"""Click the Previous Match button"""
7777
self.get_element("previous-match-button").click()
@@ -81,7 +81,7 @@ def previous_match(self) -> BasePage:
8181
self.match_dict["current"] = self.match_dict["total"]
8282
return self
8383

84-
@BasePage.chrome_context
84+
@BasePage.context_chrome
8585
def rewind_to_first_match(self) -> BasePage:
8686
"""Go back to match 1 of n"""
8787
print(self.match_dict)
@@ -90,7 +90,7 @@ def rewind_to_first_match(self) -> BasePage:
9090
self.previous_match()
9191
return self
9292

93-
@BasePage.chrome_context
93+
@BasePage.context_chrome
9494
def navigate_matches_by_keys(self, backwards=False) -> BasePage:
9595
"""Use F3 and Shift+F3 to navigate matches"""
9696
if backwards:
@@ -100,7 +100,7 @@ def navigate_matches_by_keys(self, backwards=False) -> BasePage:
100100
self.actions.send_keys(Keys.F3).perform()
101101
return self
102102

103-
@BasePage.chrome_context
103+
@BasePage.context_chrome
104104
def navigate_matches_n_times(self, n: int):
105105
for _ in range(n):
106106
self.next_match()

modules/browser_object_navigation.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,25 @@ def __init__(self, driver: Firefox, **kwargs):
2828
self.search_bar = None
2929
self.change_search_settings_button = None
3030

31-
@BasePage.content_context
31+
@BasePage.context_content
3232
def expect_in_content(self, condition) -> BasePage:
3333
"""Like BasePage.expect, but guarantee we're looking at CONTEXT_CONTENT"""
3434
self.wait.until(condition)
3535
return self
3636

37-
@BasePage.chrome_context
37+
@BasePage.context_chrome
3838
def set_awesome_bar(self) -> BasePage:
3939
"""Set the awesome_bar attribute of the Navigation object"""
4040
self.awesome_bar = self.get_element("awesome-bar")
4141
return self
4242

43-
@BasePage.chrome_context
43+
@BasePage.context_chrome
4444
def get_awesome_bar(self) -> WebElement:
4545
"""Get the Awesome Bar. Prefer this over get_element."""
4646
self.set_awesome_bar()
4747
return self.awesome_bar
4848

49-
@BasePage.chrome_context
49+
@BasePage.context_chrome
5050
def get_awesome_bar_text(self):
5151
"""
5252
Get the text directly from the awesome bar.
@@ -55,14 +55,14 @@ def get_awesome_bar_text(self):
5555
awesome_bar = self.get_element("awesome-bar").get_attribute("value")
5656
return awesome_bar
5757

58-
@BasePage.chrome_context
58+
@BasePage.context_chrome
5959
def clear_awesome_bar(self) -> BasePage:
6060
"""Clear the Awesome Bar. Prefer this over get_element("awesome-bar").clear()"""
6161
self.set_awesome_bar()
6262
self.awesome_bar.clear()
6363
return self
6464

65-
@BasePage.chrome_context
65+
@BasePage.context_chrome
6666
def type_in_awesome_bar(self, term: str) -> BasePage:
6767
"""Enter text into the Awesome Bar. You probably want self.search()"""
6868
self.set_awesome_bar()
@@ -97,7 +97,7 @@ def set_search_mode_via_awesome_bar(self, mode: str) -> BasePage:
9797
)
9898
return self
9999

100-
@BasePage.chrome_context
100+
@BasePage.context_chrome
101101
def search(self, term: str, mode=None) -> BasePage:
102102
"""
103103
Search using the Awesome Bar, optionally setting the search mode first. Returns self.
@@ -119,13 +119,13 @@ def search(self, term: str, mode=None) -> BasePage:
119119
self.type_in_awesome_bar(term + Keys.ENTER)
120120
return self
121121

122-
@BasePage.chrome_context
122+
@BasePage.context_chrome
123123
def set_search_bar(self) -> BasePage:
124124
"""Set the search_bar attribute of the Navigation object"""
125125
self.search_bar = self.find_element(By.CLASS_NAME, "searchbar-textbox")
126126
return self
127127

128-
@BasePage.chrome_context
128+
@BasePage.context_chrome
129129
def search_bar_search(self, term: str) -> BasePage:
130130
"""
131131
Search using the *Old* Search Bar. Returns self.
@@ -141,7 +141,7 @@ def search_bar_search(self, term: str) -> BasePage:
141141
self.search_bar.send_keys(term + Keys.ENTER)
142142
return self
143143

144-
@BasePage.chrome_context
144+
@BasePage.context_chrome
145145
def type_in_search_bar(self, term: str) -> BasePage:
146146
"""
147147
Type in the *Old* Search Bar. Returns self.
@@ -162,7 +162,7 @@ def open_awesome_bar_settings(self):
162162
self.click_on("search-settings")
163163
return self
164164

165-
@BasePage.chrome_context
165+
@BasePage.context_chrome
166166
def click_on_change_search_settings_button(self) -> BasePage:
167167
self.search_bar = self.find_element(By.CLASS_NAME, "searchbar-textbox")
168168
self.search_bar.click()
@@ -172,21 +172,21 @@ def click_on_change_search_settings_button(self) -> BasePage:
172172
self.change_search_settings_button.click()
173173
return self
174174

175-
@BasePage.chrome_context
175+
@BasePage.context_chrome
176176
def click_in_awesome_bar(self) -> BasePage:
177177
self.set_awesome_bar()
178178
self.awesome_bar.click()
179179
return self
180180

181-
@BasePage.chrome_context
181+
@BasePage.context_chrome
182182
def get_download_button(self) -> WebElement:
183183
"""
184184
Gets the download button WebElement
185185
"""
186186
downloads_button = self.get_element("downloads-button")
187187
return downloads_button
188188

189-
@BasePage.chrome_context
189+
@BasePage.context_chrome
190190
def wait_for_download_animation_finish(
191191
self, downloads_button: WebElement
192192
) -> BasePage:
@@ -201,15 +201,15 @@ def wait_for_download_animation_finish(
201201
logging.warning("Animation did not finish or did not play.")
202202
return self
203203

204-
@BasePage.chrome_context
204+
@BasePage.context_chrome
205205
def open_tracker_panel(self) -> BasePage:
206206
"""
207207
Clicks the shield icon and opens the panel associated with it
208208
"""
209209
self.get_element("shield-icon").click()
210210
return self
211211

212-
@BasePage.chrome_context
212+
@BasePage.context_chrome
213213
def bookmark_page_other(self) -> BasePage:
214214
self.get_element("star-button").click()
215215
dropdown = self.get_element("bookmarks-type-dropdown")
@@ -219,7 +219,7 @@ def bookmark_page_other(self) -> BasePage:
219219
self.get_element("save-bookmark-button").click()
220220
return self
221221

222-
@BasePage.chrome_context
222+
@BasePage.context_chrome
223223
def add_bookmark_advanced(
224224
self, bookmark_data: Bookmark, ba: BrowserActions
225225
) -> BasePage:
@@ -242,7 +242,7 @@ def add_bookmark_advanced(
242242
ba.switch_to_content_context()
243243
return self
244244

245-
@BasePage.chrome_context
245+
@BasePage.context_chrome
246246
def add_bookmark_via_star(self) -> BasePage:
247247
"""
248248
Bookmark a site via star button and click save on the bookmark panel
@@ -251,7 +251,7 @@ def add_bookmark_via_star(self) -> BasePage:
251251
self.get_element("save-bookmark-button").click()
252252
return self
253253

254-
@BasePage.chrome_context
254+
@BasePage.context_chrome
255255
def add_bookmark_via_menu(self) -> BasePage:
256256
"""
257257
Bookmark a site via bookmarks menu and click save on the bookmark panel
@@ -261,7 +261,7 @@ def add_bookmark_via_menu(self) -> BasePage:
261261
self.get_element("save-bookmark-button").click()
262262
return self
263263

264-
@BasePage.chrome_context
264+
@BasePage.context_chrome
265265
def toggle_bookmarks_toolbar_with_key_combo(self) -> BasePage:
266266
"""Use Cmd/Ctrl + B to open the Print Preview, wait for load"""
267267

@@ -295,7 +295,7 @@ def wait_for_item_to_download(self, filename: str) -> BasePage:
295295
self.driver.implicitly_wait(original_timeout)
296296
return self
297297

298-
@BasePage.chrome_context
298+
@BasePage.context_chrome
299299
def confirm_bookmark_exists(self, match_string: str) -> BasePage:
300300
"""
301301
For a given string, return self if it exists in the label of a bookmark, else assert False.
@@ -315,7 +315,7 @@ def confirm_bookmark_exists(self, match_string: str) -> BasePage:
315315
assert matches_short_string or matches_long_string
316316
return self
317317

318-
@BasePage.chrome_context
318+
@BasePage.context_chrome
319319
def refresh_page(self) -> BasePage:
320320
"""
321321
Refreshes the current page by clicking the refresh button in the browser.

modules/page_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def set_chrome_context(self):
105105
self.driver.set_context(self.driver.CONTEXT_CHROME)
106106

107107
@staticmethod
108-
def chrome_context(func):
108+
def context_chrome(func):
109109
"""Decorator to switch to CONTEXT_CHROME"""
110110

111111
@wraps(func)
@@ -116,7 +116,7 @@ def wrapper(self, *args, **kwargs):
116116
return wrapper
117117

118118
@staticmethod
119-
def content_context(func):
119+
def context_content(func):
120120
"""Decorator to switch to CONTEXT_CONTENT"""
121121

122122
@wraps(func)

0 commit comments

Comments
 (0)