Table of Contents

Selenium actions

The Selenium extension for Screenplay provides numerous Actions, each of which represents one of the smallest possible interactions with a web browser/page. Broadly, these actions fall into the following categories:

  • Actions which work with HTML elements (targets), such as "click on a specified element" or "type some keys into an input box". These actions will always require a target as a parameter.
  • Actions which interact directly with the web browser, such as "take a screenshot" or "clear the cookies for the current domain".
  • Actions which represent waiting for something, such as "wait until the progress bar reaches 100%" or "wait until the shopping cart items are visible".

Recall that Screenplay Actions do something without getting any result. To interrogate a web page (to observe it in some manner), use one of the Selenium extension's Questions. Below is a summary of each of these actions' usage, with a link to their detailed documentation page.

Actions that work with targets

Action Usage
ClearTheContents Remove/clear all text from the specified element, such as an <input>
Click Click on the specified element
DeselectByIndex Deselect an option from the specified <select> element by its index
DeselectByText Deselect an option from the specified <select> element by its displayed text
DeselectByValue Deselect an option from the specified <select> element by its underlying value
DeselectAll Deselects every option from the specified <select> element
SelectByIndex Select an option from the specified <select> element by its index
SelectByText Select an option from the specified <select> element by its displayed text
SelectByValue Select an option from the specified <select> element by its underlying value
SendKeys Type text (send keystrokes) whilst a specified element has focus

Actions which work with the browser

Action Usage
ClearCookies Clear the web browser cookies for the current site (domain)
ClearLocalStorage Clear the web browser local storage for the current site (domain)
DeleteTheCookie Delete a single named cookie
ExecuteJavaScript Executes a JavaScript directly in the browser
OpenUrl Directs the browser to open a specified URL
SaveScreenshot Saves a screenshot to a file

Actions which wait

Action Usage
Wait Pauses the Performance until a condition is true
WaitForSomeTime Pauses the Performance for an arbitrary amount of time