Skip to content

Commit 89e45c6

Browse files
authored
Adds sphix style definitions to important methods. (#994)
* Adds sphinx style definitions to important methods.
1 parent c4cf46b commit 89e45c6

File tree

2 files changed

+41
-16
lines changed

2 files changed

+41
-16
lines changed

src/SeleniumLibrary/__init__.py

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,15 @@ def run_keyword(self, name, args, kwargs):
363363
raise
364364

365365
def register_driver(self, driver, alias):
366+
"""Add's a `driver` to the library WebDriverCache.
367+
368+
:param driver: Instance of the Selenium `WebDriver`.
369+
:type driver: selenium.webdriver.remote.webdriver.WebDriver
370+
:param alias: Alias given for this `WebDriver` instance.
371+
:type alias: str
372+
:return: The index of the `WebDriver` instance.
373+
:rtype: int
374+
"""
366375
return self._drivers.register(driver, alias)
367376

368377
def failure_occurred(self):
@@ -402,26 +411,31 @@ def browser(self):
402411
return self.driver
403412

404413
def find_element(self, locator, parent=None):
405-
"""Find element matching ``locator``.
406-
407-
This method and :meth:`find_elements` form the recommended
408-
public API for external tools to get elements via SeleniumLibrary.
414+
"""Find element matching `locator`.
409415
410416
:param locator: Locator to use when searching the element.
411417
See library documentation for the supported locator syntax.
412-
:param parent: Optional parent ``WebElememt`` to search child elements
413-
from. By default search starts from the root using ``WebDriver``.
418+
:type locator: str or selenium.webdriver.remote.webelement.WebElement
419+
:param parent: Optional parent `WebElememt` to search child elements
420+
from. By default search starts from the root using `WebDriver`.
421+
:type parent: selenium.webdriver.remote.webelement.WebElement
422+
:return: Found `WebElement`.
414423
:rtype: selenium.webdriver.remote.webelement.WebElement
415424
:raises SeleniumLibrary.errors.ElementNotFound: If element not found.
416425
"""
417426
return self._element_finder.find(locator, parent=parent)
418427

419428
def find_elements(self, locator, parent=None):
420-
"""Find all elements matching ``locator``.
429+
"""Find all elements matching `locator`.
421430
422-
Returns a list of ``WebElement`` objects. If no matching elements
423-
are found, the list is empty. Otherwise semantics are exactly same
424-
as with the :meth:`find_element` method.
431+
:param locator: Locator to use when searching the element.
432+
See library documentation for the supported locator syntax.
433+
:type locator: str or selenium.webdriver.remote.webelement.WebElement
434+
:param parent: Optional parent `WebElememt` to search child elements
435+
from. By default search starts from the root using `WebDriver`.
436+
:type parent: selenium.webdriver.remote.webelement.WebElement
437+
:return: list of found `WebElement` or e,mpty if elements are not found.
438+
:rtype: list[selenium.webdriver.remote.webelement.WebElement]
425439
"""
426440
return self._element_finder.find(locator, first_only=False,
427441
required=False, parent=parent)
@@ -430,7 +444,7 @@ def find_elements(self, locator, parent=None):
430444
def _cache(self):
431445
warnings.warn('"SeleniumLibrary._cache" is deprecated, '
432446
'use public API instead.', DeprecationWarning)
433-
return self._browsers
447+
return self._drivers
434448

435449
def _current_browser(self):
436450
warnings.warn('"SeleniumLibrary._current_browser" is deprecated, '

src/SeleniumLibrary/base/context.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class ContextAware(object):
2222
def __init__(self, ctx):
2323
"""Base class exposing attributes from the common context.
2424
25-
:param SeleniumLibrary.SeleniumLibrary ctx:
26-
The library itself as a context object.
25+
:param ctx: The library itself as a context object.
26+
:type ctx: SeleniumLibrary.SeleniumLibrary
2727
"""
2828
self.ctx = ctx
2929

@@ -44,11 +44,15 @@ def find_element(self, locator, tag=None, required=True, parent=None):
4444
4545
:param locator: Locator to use when searching the element.
4646
See library documentation for the supported locator syntax.
47+
:type locator: str or selenium.webdriver.remote.webelement.WebElement
4748
:param tag: Limit searching only to these elements.
49+
:type tag: str
4850
:param required: Raise `ElementNotFound` if element not found when
4951
true, return `None` otherwise.
52+
:type required: True or False
5053
:param parent: Optional parent `WebElememt` to search child elements
5154
from. By default search starts from the root using `WebDriver`.
55+
:type parent: selenium.webdriver.remote.webelement.WebElement
5256
:return: Found `WebElement` or `None` if element not found and
5357
`required` is false.
5458
:rtype: selenium.webdriver.remote.webelement.WebElement
@@ -60,9 +64,16 @@ def find_element(self, locator, tag=None, required=True, parent=None):
6064
def find_elements(self, locator, tag=None, parent=None):
6165
"""Find all elements matching `locator`.
6266
63-
Always returns a list of `WebElement` objects. If no matching element
64-
is found, the list is empty. Otherwise semantics are exactly same
65-
as with :meth:`find_element`.
67+
:param locator: Locator to use when searching the element.
68+
See library documentation for the supported locator syntax.
69+
:type locator: str or selenium.webdriver.remote.webelement.WebElement
70+
:param tag: Limit searching only to these elements.
71+
:type tag: str
72+
:param parent: Optional parent `WebElememt` to search child elements
73+
from. By default search starts from the root using `WebDriver`.
74+
:type parent: selenium.webdriver.remote.webelement.WebElement
75+
:return: list of found `WebElement` or empty if elements are not found.
76+
:rtype: list[selenium.webdriver.remote.webelement.WebElement]
6677
"""
6778
return self.element_finder.find(locator, tag, False, False, parent)
6879

0 commit comments

Comments
 (0)