Skip to content

Commit fd67101

Browse files
committed
Run black and flake8
1 parent d213766 commit fd67101

13 files changed

+391
-157
lines changed

src/SeleniumLibrary/__init__.pyi

Lines changed: 153 additions & 90 deletions
Large diffs are not rendered by default.

src/SeleniumLibrary/keywords/alert.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16-
from typing import Optional, Union
16+
from typing import Union
1717

1818
from selenium.common.exceptions import TimeoutException, WebDriverException
1919
from selenium.webdriver.support import expected_conditions as EC
@@ -30,7 +30,9 @@ class AlertKeywords(LibraryComponent):
3030
_next_alert_action = ACCEPT
3131

3232
@keyword
33-
def input_text_into_alert(self, text: str, action: str = ACCEPT, timeout: Union[float, str, None] = None):
33+
def input_text_into_alert(
34+
self, text: str, action: str = ACCEPT, timeout: Union[float, str, None] = None
35+
):
3436
"""Types the given ``text`` into an input field in an alert.
3537
3638
The alert is accepted by default, but that behavior can be controlled
@@ -46,7 +48,12 @@ def input_text_into_alert(self, text: str, action: str = ACCEPT, timeout: Union[
4648
self._handle_alert(alert, action)
4749

4850
@keyword
49-
def alert_should_be_present(self, text: str = "", action: str = ACCEPT, timeout: Union[float, str, None] = None):
51+
def alert_should_be_present(
52+
self,
53+
text: str = "",
54+
action: str = ACCEPT,
55+
timeout: Union[float, str, None] = None,
56+
):
5057
"""Verifies that an alert is present and by default, accepts it.
5158
5259
Fails if no alert is present. If ``text`` is a non-empty string,
@@ -68,7 +75,9 @@ def alert_should_be_present(self, text: str = "", action: str = ACCEPT, timeout:
6875
)
6976

7077
@keyword
71-
def alert_should_not_be_present(self, action: str = ACCEPT, timeout: Union[float, str, None] = 0):
78+
def alert_should_not_be_present(
79+
self, action: str = ACCEPT, timeout: Union[float, str, None] = 0
80+
):
7281
"""Verifies that no alert is present.
7382
7483
If the alert actually exists, the ``action`` argument determines
@@ -91,7 +100,9 @@ def alert_should_not_be_present(self, action: str = ACCEPT, timeout: Union[floa
91100
raise AssertionError(f"Alert with message '{text}' present.")
92101

93102
@keyword
94-
def handle_alert(self, action: str = ACCEPT, timeout: Union[float, str, None] = None):
103+
def handle_alert(
104+
self, action: str = ACCEPT, timeout: Union[float, str, None] = None
105+
):
95106
"""Handles the current alert and returns its message.
96107
97108
By default, the alert is accepted, but this can be controlled

src/SeleniumLibrary/keywords/browsermanagement.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,9 @@ def _make_new_browser(
342342
return index
343343

344344
@keyword
345-
def create_webdriver(self, driver_name: str, alias: Optional[str] = None, kwargs={}, **init_kwargs) -> str:
345+
def create_webdriver(
346+
self, driver_name: str, alias: Optional[str] = None, kwargs={}, **init_kwargs
347+
) -> str:
346348
"""Creates an instance of Selenium WebDriver.
347349
348350
Like `Open Browser`, but allows passing arguments to the created

src/SeleniumLibrary/keywords/cookie.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,15 @@ def get_cookie(self, name: str) -> CookieInformation:
142142
return CookieInformation(**cookie)
143143

144144
@keyword
145-
def add_cookie(self, name: str, value: str, path: Optional[str] = None, domain: Optional[str] = None, secure: Optional[str] = None, expiry: Optional[str] = None):
145+
def add_cookie(
146+
self,
147+
name: str,
148+
value: str,
149+
path: Optional[str] = None,
150+
domain: Optional[str] = None,
151+
secure: Optional[str] = None,
152+
expiry: Optional[str] = None,
153+
):
146154
"""Adds a cookie to your current session.
147155
148156
``name`` and ``value`` are required, ``path``, ``domain``, ``secure``

src/SeleniumLibrary/keywords/element.py

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616
from collections import namedtuple
17-
from typing import List, Optional
17+
from typing import List, Optional, Tuple
1818

1919
from robot.utils import plural_or_not
2020
from selenium.webdriver.common.action_chains import ActionChains
@@ -51,7 +51,11 @@ def get_webelements(self, locator: str) -> List[WebElement]:
5151

5252
@keyword
5353
def element_should_contain(
54-
self, locator: str, expected: str, message: Optional[str] = None, ignore_case: bool = False
54+
self,
55+
locator: str,
56+
expected: str,
57+
message: Optional[str] = None,
58+
ignore_case: bool = False,
5559
):
5660
"""Verifies that element ``locator`` contains text ``expected``.
5761
@@ -85,7 +89,11 @@ def element_should_contain(
8589

8690
@keyword
8791
def element_should_not_contain(
88-
self, locator: str, expected: str, message: Optional[str] = None, ignore_case: bool = False
92+
self,
93+
locator: str,
94+
expected: str,
95+
message: Optional[str] = None,
96+
ignore_case: bool = False,
8997
):
9098
"""Verifies that element ``locator`` does not contain text ``expected``.
9199
@@ -133,7 +141,11 @@ def page_should_contain(self, text: str, loglevel: str = "TRACE"):
133141

134142
@keyword
135143
def page_should_contain_element(
136-
self, locator: str, message: Optional[str] = None, loglevel: Optional[str] = "TRACE", limit: Optional[int] = None
144+
self,
145+
locator: str,
146+
message: Optional[str] = None,
147+
loglevel: Optional[str] = "TRACE",
148+
limit: Optional[int] = None,
137149
):
138150
"""Verifies that element ``locator`` is found on the current page.
139151
@@ -189,7 +201,9 @@ def page_should_not_contain(self, text: str, loglevel: str = "TRACE"):
189201
self.info(f"Current page does not contain text '{text}'.")
190202

191203
@keyword
192-
def page_should_not_contain_element(self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"):
204+
def page_should_not_contain_element(
205+
self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"
206+
):
193207
"""Verifies that element ``locator`` is not found on the current page.
194208
195209
See the `Locating elements` section for details about the locator
@@ -284,7 +298,9 @@ def element_should_be_visible(self, locator: str, message: Optional[str] = None)
284298
self.info(f"Element '{locator}' is displayed.")
285299

286300
@keyword
287-
def element_should_not_be_visible(self, locator: str, message: Optional[str] = None):
301+
def element_should_not_be_visible(
302+
self, locator: str, message: Optional[str] = None
303+
):
288304
"""Verifies that the element identified by ``locator`` is NOT visible.
289305
290306
Passes if the element does not exists. See `Element Should Be Visible`
@@ -302,7 +318,11 @@ def element_should_not_be_visible(self, locator: str, message: Optional[str] = N
302318

303319
@keyword
304320
def element_text_should_be(
305-
self, locator: str, expected: str, message: Optional[str] = None, ignore_case: bool = False
321+
self,
322+
locator: str,
323+
expected: str,
324+
message: Optional[str] = None,
325+
ignore_case: bool = False,
306326
):
307327
"""Verifies that element ``locator`` contains exact the text ``expected``.
308328
@@ -334,7 +354,11 @@ def element_text_should_be(
334354

335355
@keyword
336356
def element_text_should_not_be(
337-
self, locator: str, not_expected: str, message: Optional[str] = None, ignore_case: bool = False
357+
self,
358+
locator: str,
359+
not_expected: str,
360+
message: Optional[str] = None,
361+
ignore_case: bool = False,
338362
):
339363
"""Verifies that element ``locator`` does not contain exact the text ``not_expected``.
340364
@@ -419,7 +443,7 @@ def get_horizontal_position(self, locator: str) -> int:
419443
return self.find_element(locator).location["x"]
420444

421445
@keyword
422-
def get_element_size(self, locator: str) -> int:
446+
def get_element_size(self, locator: str) -> Tuple[int, int]:
423447
"""Returns width and height of the element identified by ``locator``.
424448
425449
See the `Locating elements` section for details about the locator
@@ -571,7 +595,9 @@ def click_link(self, locator: str, modifier: Optional[str] = False):
571595
self._click_with_modifier(locator, ["link", "link"], modifier)
572596

573597
@keyword
574-
def click_element(self, locator: str, modifier: Optional[str] = False, action_chain: bool = False):
598+
def click_element(
599+
self, locator: str, modifier: Optional[str] = False, action_chain: bool = False
600+
):
575601
"""Click the element identified by ``locator``.
576602
577603
See the `Locating elements` section for details about the locator
@@ -953,7 +979,9 @@ def mouse_down_on_link(self, locator: str):
953979
action.click_and_hold(element).perform()
954980

955981
@keyword
956-
def page_should_contain_link(self, locator: str, message: Optional[str] = None, loglevel: str="TRACE"):
982+
def page_should_contain_link(
983+
self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"
984+
):
957985
"""Verifies link identified by ``locator`` is found from current page.
958986
959987
See the `Locating elements` section for details about the locator
@@ -966,7 +994,9 @@ def page_should_contain_link(self, locator: str, message: Optional[str] = None,
966994
self.assert_page_contains(locator, "link", message, loglevel)
967995

968996
@keyword
969-
def page_should_not_contain_link(self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"):
997+
def page_should_not_contain_link(
998+
self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"
999+
):
9701000
"""Verifies link identified by ``locator`` is not found from current page.
9711001
9721002
See the `Locating elements` section for details about the locator
@@ -991,7 +1021,9 @@ def mouse_down_on_image(self, locator: str):
9911021
action.click_and_hold(element).perform()
9921022

9931023
@keyword
994-
def page_should_contain_image(self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"):
1024+
def page_should_contain_image(
1025+
self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"
1026+
):
9951027
"""Verifies image identified by ``locator`` is found from current page.
9961028
9971029
See the `Locating elements` section for details about the locator
@@ -1004,7 +1036,9 @@ def page_should_contain_image(self, locator: str, message: Optional[str] = None,
10041036
self.assert_page_contains(locator, "image", message, loglevel)
10051037

10061038
@keyword
1007-
def page_should_not_contain_image(self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"):
1039+
def page_should_not_contain_image(
1040+
self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"
1041+
):
10081042
"""Verifies image identified by ``locator`` is not found from current page.
10091043
10101044
See the `Locating elements` section for details about the locator
@@ -1033,7 +1067,9 @@ def get_element_count(self, locator: str) -> int:
10331067
return len(self.find_elements(locator))
10341068

10351069
@keyword
1036-
def add_location_strategy(self, strategy_name: str, strategy_keyword: str, persist: bool = False):
1070+
def add_location_strategy(
1071+
self, strategy_name: str, strategy_keyword: str, persist: bool = False
1072+
):
10371073
"""Adds a custom location strategy.
10381074
10391075
See `Custom locators` for information on how to create and use

src/SeleniumLibrary/keywords/formelement.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ def checkbox_should_not_be_selected(self, locator: str):
6767
raise AssertionError(f"Checkbox '{locator}' should not have been selected.")
6868

6969
@keyword
70-
def page_should_contain_checkbox(self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"):
70+
def page_should_contain_checkbox(
71+
self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"
72+
):
7173
"""Verifies checkbox ``locator`` is found from the current page.
7274
7375
See `Page Should Contain Element` for an explanation about ``message``
@@ -79,7 +81,9 @@ def page_should_contain_checkbox(self, locator: str, message: Optional[str] = No
7981
self.assert_page_contains(locator, "checkbox", message, loglevel)
8082

8183
@keyword
82-
def page_should_not_contain_checkbox(self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"):
84+
def page_should_not_contain_checkbox(
85+
self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"
86+
):
8387
"""Verifies checkbox ``locator`` is not found from the current page.
8488
8589
See `Page Should Contain Element` for an explanation about ``message``
@@ -119,7 +123,9 @@ def unselect_checkbox(self, locator: str):
119123
element.click()
120124

121125
@keyword
122-
def page_should_contain_radio_button(self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"):
126+
def page_should_contain_radio_button(
127+
self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"
128+
):
123129
"""Verifies radio button ``locator`` is found from current page.
124130
125131
See `Page Should Contain Element` for an explanation about ``message``
@@ -275,7 +281,9 @@ def input_text(self, locator: str, text: str, clear: bool = True):
275281
self._input_text_into_text_field(locator, text, clear)
276282

277283
@keyword
278-
def page_should_contain_textfield(self, locator: str, message: Optional[str] = None, loglevel: str="TRACE"):
284+
def page_should_contain_textfield(
285+
self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"
286+
):
279287
"""Verifies text field ``locator`` is found from current page.
280288
281289
See `Page Should Contain Element` for an explanation about ``message``
@@ -301,7 +309,9 @@ def page_should_not_contain_textfield(
301309
self.assert_page_not_contains(locator, "text field", message, loglevel)
302310

303311
@keyword
304-
def textfield_should_contain(self, locator: str, expected: str, message: Optional[str] = None):
312+
def textfield_should_contain(
313+
self, locator: str, expected: str, message: Optional[str] = None
314+
):
305315
"""Verifies text field ``locator`` contains text ``expected``.
306316
307317
``message`` can be used to override the default error message.
@@ -320,7 +330,9 @@ def textfield_should_contain(self, locator: str, expected: str, message: Optiona
320330
self.info(f"Text field '{locator}' contains text '{expected}'.")
321331

322332
@keyword
323-
def textfield_value_should_be(self, locator: str, expected: str, message: Optional[str] = None):
333+
def textfield_value_should_be(
334+
self, locator: str, expected: str, message: Optional[str] = None
335+
):
324336
"""Verifies text field ``locator`` has exactly text ``expected``.
325337
326338
``message`` can be used to override default error message.
@@ -339,7 +351,9 @@ def textfield_value_should_be(self, locator: str, expected: str, message: Option
339351
self.info(f"Content of text field '{locator}' is '{expected}'.")
340352

341353
@keyword
342-
def textarea_should_contain(self, locator: str, expected: str, message: Optional[str] = None):
354+
def textarea_should_contain(
355+
self, locator: str, expected: str, message: Optional[str] = None
356+
):
343357
"""Verifies text area ``locator`` contains text ``expected``.
344358
345359
``message`` can be used to override default error message.
@@ -358,7 +372,9 @@ def textarea_should_contain(self, locator: str, expected: str, message: Optional
358372
self.info(f"Text area '{locator}' contains text '{expected}'.")
359373

360374
@keyword
361-
def textarea_value_should_be(self, locator: str, expected: str, message: Optional[str] = None):
375+
def textarea_value_should_be(
376+
self, locator: str, expected: str, message: Optional[str] = None
377+
):
362378
"""Verifies text area ``locator`` has exactly text ``expected``.
363379
364380
``message`` can be used to override default error message.
@@ -377,7 +393,9 @@ def textarea_value_should_be(self, locator: str, expected: str, message: Optiona
377393
self.info(f"Content of text area '{locator}' is '{expected}'.")
378394

379395
@keyword
380-
def page_should_contain_button(self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"):
396+
def page_should_contain_button(
397+
self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"
398+
):
381399
"""Verifies button ``locator`` is found from current page.
382400
383401
See `Page Should Contain Element` for an explanation about ``message``
@@ -393,7 +411,9 @@ def page_should_contain_button(self, locator: str, message: Optional[str] = None
393411
self.assert_page_contains(locator, "button", message, loglevel)
394412

395413
@keyword
396-
def page_should_not_contain_button(self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"):
414+
def page_should_not_contain_button(
415+
self, locator: str, message: Optional[str] = None, loglevel: str = "TRACE"
416+
):
397417
"""Verifies button ``locator`` is not found from current page.
398418
399419
See `Page Should Contain Element` for an explanation about ``message``

src/SeleniumLibrary/keywords/javascript.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ def _separate_code_and_args(self, code):
126126
self._check_marker_error(code)
127127
index = self._get_marker_index(code)
128128
if self.arg_marker not in code:
129-
return code[index.js + 1 :], []
129+
return code[index.js + 1:], []
130130
if self.js_marker not in code:
131-
return code[0 : index.arg], code[index.arg + 1 :]
131+
return code[0: index.arg], code[index.arg + 1:]
132132
else:
133133
if index.js == 0:
134-
return code[index.js + 1 : index.arg], code[index.arg + 1 :]
134+
return code[index.js + 1: index.arg], code[index.arg + 1:]
135135
else:
136-
return code[index.js + 1 :], code[index.arg + 1 : index.js]
136+
return code[index.js + 1:], code[index.arg + 1: index.js]
137137

138138
def _check_marker_error(self, code):
139139
if not code:

src/SeleniumLibrary/keywords/screenshot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ def _capture_page_screen_to_log(self):
125125
return EMBED
126126

127127
@keyword
128-
def capture_element_screenshot(self, locator: str, filename: str = DEFAULT_FILENAME_ELEMENT) -> str:
128+
def capture_element_screenshot(
129+
self, locator: str, filename: str = DEFAULT_FILENAME_ELEMENT
130+
) -> str:
129131
"""Captures a screenshot from the element identified by ``locator`` and embeds it into log file.
130132
131133
See `Capture Page Screenshot` for details about ``filename`` argument.

0 commit comments

Comments
 (0)