Skip to content

Commit

Permalink
add several aliases for Actions and Questions.
Browse files Browse the repository at this point in the history
  • Loading branch information
perrygoy committed May 15, 2024
1 parent be1b50f commit 443fb20
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 3 deletions.
29 changes: 28 additions & 1 deletion docs/extended_api/actions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ see ScreenPy's :external+screenpy:ref:`actions api` reference.
Click
-----

**Aliases:**
``Clicks``

.. autoclass:: Click
:members:
:exclude-members: on
Expand All @@ -19,6 +22,9 @@ Click
Enter
-----

**Aliases:**
``Enters``

.. autoclass:: Enter
:members:
:exclude-members: into, the_password
Expand All @@ -27,7 +33,12 @@ Enter
Open
----

**Aliases:** ``Visit``
**Aliases:**
``GoTo``,
``GoesTo``,
``Opens``,
``Visit``
``Visits``,

.. autoclass:: Open
:members:
Expand All @@ -36,13 +47,23 @@ Open
RefreshThePage
--------------

**Aliases:**
``RefreshesThePage``,
``Refresh``,
``Refreshes``

.. autoclass:: RefreshThePage
:members:


SaveScreenshot
--------------

**Aliases:**
``SavesScreenshot``,
``SaveAScreenshot``,
``SavesAScreenshot``,

.. autoclass:: SaveScreenshot
:members:
:exclude-members: and_attach_it_with
Expand All @@ -51,6 +72,9 @@ SaveScreenshot
Scroll
------

**Aliases:**
``Scrolls``

.. autoclass:: Scroll
:members:
:exclude-members: direction_to_log
Expand All @@ -59,6 +83,9 @@ Scroll
Select
------

**Aliases:**
``Selects``

.. autoclass:: Select
:members:
:exclude-members: the_options, from_
16 changes: 16 additions & 0 deletions docs/extended_api/questions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,52 @@ These are the Questions added in ScreenPy Playwright.

.. module:: screenpy_playwright.questions


Attribute
---------

**Aliases:**
``TheAttribute``

.. autoclass:: Attribute
:members:


BrowserURL
----------

**Aliases:**
``TheBrowserURL``

.. autoclass:: BrowserURL
:members:


Element
-------

**Aliases:**
``TheElement``

.. autoclass:: Element
:members:


Number
------

**Aliases:**
``TheNumber``

.. autoclass:: Number
:members:


Text
----

**Aliases:**
``TheText``

.. autoclass:: Text
:members:
22 changes: 20 additions & 2 deletions screenpy_playwright/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,35 @@
from .scroll import Scroll
from .select import Select

# Natural-language-enabling syntactic sugar
Visit = Open
# Natural-language-enabling aliases
Clicks = Click
Enters = Enter
GoTo = GoesTo = Visit = Visits = Opens = Open
Refresh = Refreshes = RefreshesThePage = RefreshThePage
SavesScreenshot = SavesAScreenshot = SaveAScreenshot = SaveScreenshot
Scrolls = Scroll
Selects = Select


__all__ = [
"Click",
"Clicks",
"Enter",
"Enters",
"GoTo",
"GoesTo",
"Open",
"Opens",
"RefreshThePage",
"RefreshesThePage",
"SaveScreenshot",
"SaveAScreenshot",
"SavesScreenshot",
"SavesAScreenshot",
"Scroll",
"Scrolls",
"Select",
"Selects",
"Visit",
"Visits",
]
12 changes: 12 additions & 0 deletions screenpy_playwright/questions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,22 @@
from .number import Number
from .text import Text

# Natural-language-enabling aliases
TheAttribute = Attribute
TheBrowserURL = BrowserURL
TheElement = Element
TheNumber = Number
TheText = Text

__all__ = [
"Attribute",
"BrowserURL",
"Element",
"Number",
"Text",
"TheAttribute",
"TheBrowserURL",
"TheElement",
"TheNumber",
"TheText",
]
34 changes: 34 additions & 0 deletions tests/test_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,39 @@ def test_screenpy_playwright() -> None:
"BrowserURL",
"BrowseTheWebSynchronously",
"Click",
"Clicks",
"Element",
"Enter",
"Enters",
"GoesTo",
"GoTo",
"IsVisible",
"NoPageError",
"Number",
"Open",
"Opens",
"PageObject",
"RefreshesThePage",
"RefreshThePage",
"SaveAScreenshot",
"SavesAScreenshot",
"SaveScreenshot",
"SavesScreenshot",
"Scroll",
"Scrolls",
"Select",
"Selects",
"Target",
"TargetingError",
"Text",
"TheAttribute",
"TheBrowserURL",
"TheElement",
"TheNumber",
"TheText",
"Visible",
"Visit",
"Visits",
]
assert sorted(screenpy_playwright.__all__) == sorted(expected)

Expand All @@ -37,13 +54,25 @@ def test_abilities() -> None:
def test_actions() -> None:
expected = [
"Click",
"Clicks",
"Enter",
"Enters",
"GoTo",
"GoesTo",
"Open",
"Opens",
"RefreshThePage",
"RefreshesThePage",
"SaveScreenshot",
"SaveAScreenshot",
"SavesScreenshot",
"SavesAScreenshot",
"Scroll",
"Scrolls",
"Select",
"Selects",
"Visit",
"Visits",
]
assert sorted(screenpy_playwright.actions.__all__) == sorted(expected)

Expand All @@ -55,6 +84,11 @@ def test_questions() -> None:
"Element",
"Number",
"Text",
"TheAttribute",
"TheBrowserURL",
"TheElement",
"TheNumber",
"TheText",
]
assert sorted(screenpy_playwright.questions.__all__) == sorted(expected)

Expand Down

0 comments on commit 443fb20

Please sign in to comment.