Skip to content

Commit

Permalink
Massive Documentation improvement by Niklas!
Browse files Browse the repository at this point in the history
Documentation/test update
  • Loading branch information
Snooz82 authored Aug 20, 2020
2 parents bc7b65c + 92f1599 commit ca78b8b
Show file tree
Hide file tree
Showing 14 changed files with 999 additions and 606 deletions.
376 changes: 343 additions & 33 deletions Browser/browser.py
100644 → 100755

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Browser/keywords/browser_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _get_screenshot_path(self, filename: str) -> Path:
def take_screenshot(self, filename: str = "", selector: str = ""):
"""Takes a screenshot of the current window and saves it to ``path``. Saves it as a png.
``filename`` <str> Filename into which to save. The file will be saved into the robot framework output directory.
``filename`` <str> Filename into which to save. The file will be saved into the robot framework output directory by default.
String ``{index}`` in path will be replaced with a rolling number. Use this to not override filenames.
``selector`` <str> Take a screenshot of the element matched by selector.
Expand Down
20 changes: 11 additions & 9 deletions Browser/keywords/cookie.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ def add_cookie(
``secure`` <bool> Sets the secure token.
``samesite`` <Strict|Lax|None> Sets the samesite mode.
``samesite`` < ``Strict`` | ``Lax`` | ``None`` > Sets the samesite mode.
Example:
| `Add Cookie` | foo | bar | http://address.com/path/to/site | | # Using url argument. |
| `Add Cookie` | foo | bar | domain=example.com | path=/foo/bar | # Using domain and url arguments. |
| `Add Cookie` | foo | bar | http://address.com/path/to/site | expiry=2027-09-28 16:21:35 | # Expiry as timestamp. |
| `Add Cookie` | foo | bar | http://address.com/path/to/site | expiry=1822137695 | # Expiry as epoch seconds. |
| `Add Cookie` foo bar http://address.com/path/to/site # Using url argument.
| `Add Cookie` foo bar domain=example.com path=/foo/bar # Using domain and url arguments.
| `Add Cookie` foo bar http://address.com/path/to/site expiry=2027-09-28 16:21:35 # Expiry as timestamp.
| `Add Cookie` foo bar http://address.com/path/to/site expiry=1822137695 # Expiry as epoch seconds.
"""
params = locals_to_params(locals())
if expires:
Expand Down Expand Up @@ -152,6 +152,8 @@ def get_cookie(
) -> Union[DotDict, str]:
"""Returns information of cookie with ``name`` as a Robot Framework dot dictionary or a string.
``cookie`` <str> Name of the cookie to be retrieved.
If ``return_type`` is ``dictionary`` or ``dict`` then keyword returns a of Robot Framework
[https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#accessing-list-and-dictionary-items|dot dictionary]
The dictionary contains all possible key value pairs of the cookie. If ``return_type`` is ``string`` or ``str``,
Expand All @@ -161,7 +163,7 @@ def get_cookie(
If no cookie is found with ``name`` keyword fails. The cookie dictionary contains
details about the cookie. Keys available in the dictionary are documented in the table below.
| Value | Explanation |
| *Value* | *Explanation* |
| name | The name of a cookie, mandatory. |
| value | Value of the cookie, mandatory. |
| url | Define the scope of the cookie, what URLs the cookies should be sent to. |
Expand All @@ -177,9 +179,9 @@ def get_cookie(
for details about each attribute.
Example:
| ${cookie} = | Get Cookie | Foobar |
| Should Be Equal | ${cookie.value} | Tidii |
| Should Be Equal | ${cookie.expiry.year} | ${2020} |
| ${cookie}= Get Cookie Foobar
| Should Be Equal ${cookie.value} Tidii
| Should Be Equal ${cookie.expiry.year} ${2020}
"""
_, cookies = self._get_cookies()
for cookie_dict in cookies:
Expand Down
8 changes: 4 additions & 4 deletions Browser/keywords/device_descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def get_device(self, name: str):
before using ensure your active page is on that context.
Usage:
| ${device}= | Get Device | iPhone X
| | New Context | &{device}
| | New Page |
| | Get Viewport Size | returns { "width": 375, "height": 812 }
| ${device}= Get Device iPhone X
| New Context &{device}
| New Page
| Get Viewport Size returns { "width": 375, "height": 812 }
"""
with self.playwright.grpc_channel() as stub:
response = stub.GetDevice(Request().Device(name=name))
Expand Down
2 changes: 1 addition & 1 deletion Browser/keywords/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def highlight_elements(
``width`` <str> Sets the width of the higlight border. Defaults to 2px.
``style`` <solid|dotted|double|dashed> Sets the style of the border. Defaults to dotted.
``style`` < ``solid`` | ``dotted`` | ``double`` | ``dashed`` > Sets the style of the border. Defaults to dotted.
``color`` <str> Sets the color of the border. Valid colors i.e. are:
``red``, ``blue``, ``yellow``, ``pink``, ``black``
Expand Down
32 changes: 14 additions & 18 deletions Browser/keywords/getters.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def get_selected_options(
``selector`` <str> Selector from which the info is to be retrieved. **Required**
``option_attribute`` <SelectAttribute.label> Which attribute shall be returned/verified.
Allowed values are ``<"value"|"label"|"text"|"index">``. Defaults to label.
Allowed values are ``< ``value`` | ``label`` | ``text`` | ``index`` >``. Defaults to label.
``assertion_operator`` <AssertionOperator> See `Assertions` for further details. Defaults to None.
Expand All @@ -209,13 +209,13 @@ def get_selected_options(
Example:
| `Select Options By` | label | //select[2] | Email | Mobile | | |
| ${selected_list} | `Get Selected Options` | //select[2] | | | | # getter |
| `Get Selected Options` | //select[2] | label | `==` | Mobile | Mail | #assertion content |
| `Select Options By` | label | select#names | 2 | 4 | | |
| `Get Selected Options` | select#names | index | `==` | 2 | 4 | #assertion index |
| `Get Selected Options` | select#names | label | *= | Mikko | | #assertion contains |
| `Get Selected Options` | select#names | label | validate | len(value) == 3 | | #assertion length |
| `Select Options By` label //select[2] Email Mobile
| ${selected_list} `Get Selected Options` //select[2] # getter
| `Get Selected Options` //select[2] label `==` Mobile Mail #assertion content
| `Select Options By` label select#names 2 4
| `Get Selected Options` select#names index `==` 2 4 #assertion index
| `Get Selected Options` select#names label *= Mikko #assertion contain
| `Get Selected Options` select#names label validate len(value) == 3 #assertion length
"""
with self.playwright.grpc_channel() as stub:
Expand Down Expand Up @@ -296,8 +296,6 @@ def get_element_count(
``assertion_operator`` <AssertionOperator> See `Assertions` for further details. Defaults to None.
``expected_value`` <str|int> Expected value for the counting
"""
with self.playwright.grpc_channel() as stub:
response = stub.GetElementCount(
Expand Down Expand Up @@ -460,15 +458,13 @@ def get_boundingbox(
See `Assertions` for further details for the assertion arguments. Defaults to None.
Example use:
| ${bounding_box}= Get BoundingBox id=element # unfiltered
| Log ${bounding_box} # {'x': 559.09375, 'y': 75.5, 'width': 188.796875, 'height': 18}
| ${x}= Get BoundingBox id=element x # filtered
| Log X: ${x} # X: 559.09375
| ${bounding_box}= Get BoundingBox id=element # unfiltered
| Log ${bounding_box} # {'x': 559.09375, 'y': 75.5, 'width': 188.796875, 'height': 18}
| ${x}= Get BoundingBox id=element x # filtered
| Log X: ${x} # X: 559.09375
| # Assertions:
| Get BoundingBox id=element width > 180
| Get BoundingBox id=element ALL validate value['x'] > value['y']*2
| Get BoundingBox id=element width > 180
| Get BoundingBox id=element ALL validate value['x'] > value['y']*2
"""
with self.playwright.grpc_channel() as stub:
response = stub.GetBoundingBox(Request.ElementSelector(selector=selector))
Expand Down
Loading

0 comments on commit ca78b8b

Please sign in to comment.