Additional Actions
ScreenPy Playwright adds many additional Actions. For the base Action list, see ScreenPy’s Actions API reference.
Click
Enter
- class Enter(text: str, *, mask: bool = False)
Enter text into an input field.
- Abilities Required:
Examples:
the_actor.attempts_to(Enter("Hello!").into_the(GREETING_INPUT)) the_actor.attempts_to(Enter.the_text("eggs").into_the(GROCERY_FIELD)) the_actor.attempts_to(Enter.the_secret("12345").into_the(PASSWORD_FIELD))
- static the_text(text: str) Enter
Provide the text to enter into the field.
- Args:
text: the text to enter into the field.
- Returns:
A new instance of Enter, with mask et to False.
- static the_secret(text: str) Enter
Provide the SECRET text to enter into the field.
The text will be masked, and appear as “[CENSORED]”.
- Returns:
A new instance of Enter, with mask set to True.
- static the_password(text: str) Enter
Provide the SECRET text to enter into the field.
The text will be masked, and appear as “[CENSORED]”.
- Returns:
A new instance of Enter, with mask set to True.
Open
Aliases: Visit
- class Open(location: str | PageObject)
Go to a specific URL!
This Action supports using the BASE_URL environment variable to set a base URL. If you set BASE_URL, the url passed in to this Action will be appended to the end of it. For example, if you have
BASE_URL=http://localhost, thenOpen("/home")will send your browser to “http://localhost/home”.If you pass in an object, make sure the object has a
urlproperty that can be referenced by this Action.- Abilities Required:
Examples:
the_actor.attempts_to(Open("https://www.nintendo.com/"))
SaveScreenshot
- class SaveScreenshot(path: str)
Save a screenshot of the Actor’s current page.
Use the
and_attach_it()method to indicate that this screenshot should be attached to all reports through the Narrator’s adapters. This method also accepts any keyword arguments those adapters might require.- Abilities Required:
Examples:
the_actor.attempts_to(SaveScreenshot("screenshot.png")) the_actor.attempts_to(SaveScreenshot.as_(filepath)) # attach file to the Narrator's reports (behavior depends on adapter). the_actor.attempts_to(SaveScreenshot.as_(filepath).and_attach_it()) # using screenpy_adapter_allure plugin! from allure_commons.types import AttachmentTypes the_actor.attempts_to( SaveScreenshot.as_(filepath).and_attach_it_with( attachment_type=AttachmentTypes.PNG, ), )
- classmethod as_(path: str) Self
Supply the name and/or filepath for the screenshot.
If only a name is supplied, the screenshot will appear in the current working directory.
- Args:
path: The filepath for the screenshot, including its name.
- Returns:
Self