The Browser Actions category contains actions that resize the browser window, perform navigation, take screenshots and handle native browser dialogs (alert, confirm, prompt and beforeunload).
Resizes the browser window to the specified dimensions.
|Width||Number||The width (in pixels).|
|Height||Number||The height (in pixels).|
Resizes the browser window to fit the screen.
Resizes the browser window to fit the device's screen size.
|Device||String||The device name. You can select it from the drop-down list.|
|Portrait Orientation||Boolean||Specifies whether the window should fit the device screen in portrait orientation. If unchecked, landscape orientation is used.|
Navigates the browser to the specified URL.
|Url||String||The URL to navigate to. Absolute or relative to the current page.|
Takes a screenshot of the tested webpage.
|Path (optional)||String||The screenshot file's relative path and name. Use the run configuration's Screenshot path option to specify the base directory to store screenshots (see Run Configuration Dialog).|
TestCafe cannot take screenshots on remote devices.
Defines how subsequent native dialogs are handled. Call Handle Native Dialogs before the first action that triggers a dialog. Otherwise, the test fails when the dialog appears.
You do not have to call Handle Native Dialogs before each dialog. You can call it once to handle all the dialogs during a test.
Call Handle Native Dialogs before the first test action to handle native dialogs that pop up during the page load.
Handle Native Dialogs settings affect all dialogs that originate from the main window and iframes, regardless of the current browsing context.
You can choose whether to use the default actions to handle all native dialogs or handle specific dialogs with custom actions.
Select the Handle all dialogs radio button to handle all dialogs with the default actions.
The following table describes how dialogs are handled in this instance:
|alert||The OK button is clicked.|
|confirm||The Cancel button is clicked.|
|prompt||Nothing is typed into an input. The Cancel button is clicked.|
|beforeunload||The Leave button is clicked.|
Select the Handle specific dialogs radio button to specify the expected dialogs' parameters and actions used to handle them.
Use the + Alert, + Confirm, + Prompt and + Beforeunload buttons to specify parameters for different dialog types.
You can click each button several times to specify the expected parameters and actions for multiple dialogs.
Each click adds a new rule. You can specify a parameter (like a dialog message) in one rule and omit it in the other. In this instance, the first rule is used to handle a dialog with the specified message, while the second handles all other dialogs.
If you call Handle Native Dialogs multiple times, new settings take priority and dialogs expected previously are no longer handled.
|Message||The expected dialog message. If this option is disabled, dialogs containing any message are handled.|
|Origin URL||The expected dialog origin URL (the main window's or an iframe's URL). If this option is disabled, dialogs from all URLs are handled.|
If a dialog with a different message or origin URL appears, the test fails.
|Close Action||The action that closes the dialog. For instance, OK or Cancel.||Confirm, Prompt|
|Input Text||Text to type into an input field.||Prompt|
The beforeunload dialog can be closed only with the Leave button.
Disables handling native dialogs. Use this action to ensure that no dialogs appear after it is called.
If a native dialog pops up after this action, the test fails.