Window and tab actions
I have an open browser
Opens a browser if none are open
I have an open browser
I have no open browser
Closes all open browsers
I have no open browser
I start a new browser
Starts a new browser session (or switches to exising one if it is already open).
I start a new browser
I close the[ current] browser
Closes the current browser session (or does nothing if one is not open).
I close the[ current] browser
I start a browser for <name>
Starts a new browser session with the given name (closes any existing browser of that name first).
I start a browser for <name>
I switch to <name>
Switches to a named browser session (starts a new browser if one of that name is not already open). All browser actions performed after this will execute in the named session.
I switch to <name>
Where
<name>is the name of the browser session to switch to
Example
When I start a browser for React
And I navigate to "https://todomvc.com/examples/react/dist"
And I start a browser for Vue
And I navigate to "https://todomvc.com/examples/vue/"
And I switch to React
Then the current URL should contain "react"
I close the browser for <name>
Closes a named browser session (does nothing if one of that name is not open).
I close the browser for <name>
I start a new browser <tab|window>
Starts a new browser tab or window (or starts a new browser session if one is not open).
I start a new browser <tab|window>
I switch to <tab|window> <occurrence>
Switches to a previously opened tab or window occurrence.
I switch to <tab|window> <occurrence>
Where
<tab|window>is eithertaborwindow<occurrence>is the tab or window occurrence to switch to (1st opened is occurrence 1, 2nd is 2, ..)- Note: the occurrence number of the default tab/window in a new browser session is 0
Example
When I navigate to "https://google.com"
And I start a new browser tab
And I navigate to "https://todomvc.com/examples/react/dist"
And I switch to window 1
Then the page title should contain "Google"
I close <tab|window> <occurrence>
Closes a previously opened tab or window occurrence.
I close <tab|window> <occurrence>
Where
<tab|window>is eithertaborwindow<occurrence>is the tab or window occurrence to close to (1st opened is occurrence 1, 2nd is 2, ..)- Note: you cannot close the default tab/window opened by starting a new browser session with this DSL. Use
I close the[ current] browserinstead in that case.
- Note: you cannot close the default tab/window opened by starting a new browser session with this DSL. Use
Example
When I navigate to "https://google.com"
And I start a new browser tab
And I navigate to "https://todomvc.com/examples/react/dist"
And I close tab 1
Then the page title should contain "Google"
If used in conjunction with @Try, will switch to the parent window regardless of whether or not a tab or window was closed (since 3.12.4).
I switch to the child <tab|window>
Switches to the most recently opened child tab or window (without closing the parent window)
I switch to the child <tab|window>
I close the child <tab|window>
Closes the currently active child tab or window and passes control back to the parent window.
I close the child <tab|window>
Where
<tab|window>is eithertaborwindow
Example
Given the new tab button can be located by name "newbrowsertab453"
When I navigate to "https://nxtgenaiacademy.com/multiplewindows/"
And I click the new tab button
And I switch to the child tab
And I close the child tab
If used in conjunction with @Try, will switch to the parent window regardless of whether or not a child window was closed (since 3.12.4).
I switch to child <tab|window> <occurrence>
Switches to a child tab or window occurrence (without closing the parent window) or reports and error if there is no child window.
I switch to child <tab|window> <occurrence>
Where
<tab|window>is eithertaborwindow<occurrence>is the tab or window occurrence to switch to (1st opened is occurrence 1, 2nd is 2, ..)
Example
Given the new window button can be located by name "newbrowserwindow123"
When I navigate to "https://nxtgenaiacademy.com/multiplewindows/"
And I click the new window button
And I switch to child window 1
I close child <tab|window> <occurrence>
Closes a child tab or window occurrence and passes control back to the parent window.
I close child <tab|window> <occurrence>
Where
<tab|window>is eithertaborwindow<occurrence>is the tab or window occurrence to close (1st opened is occurrence 1, 2nd is 2, ..)
Example
Given the new tab button can be located by name "newbrowsertab453"
When I navigate to "https://nxtgenaiacademy.com/multiplewindows/"
And I click the new tab button
And I switch to child tab 1
And I close child tab 1
If used in conjunction with @Try, will switch to the parent window regardless of whether or not a child window was closed (since 3.12.4).
I switch to the parent <tab|window>
Switches to the parent window of the currently active window (without closing the currently active window) or stays on the root window if there is no other window open.
I switch to the parent <tab|window>
Where
<tab|window>is eithertaborwindow
Example
Given the new window button can be located by name "newbrowserwindow123"
When I navigate to "https://nxtgenaiacademy.com/multiplewindows/"
And I click the new window button
And I switch to child window 1
And I switch to the parent window
I switch to the root <tab|window>
Switches to the topmost parent window (without closing the currently active window) or stays on the current window if it is the root window.
I switch to the root <tab|window>
Where
<tab|window>is eithertaborwindow
Example
Given the new window button can be located by name "newbrowserwindow123"
When I navigate to "https://nxtgenaiacademy.com/multiplewindows/"
And I click the new window button
And I switch to child window 1
And I switch to the root window
I <maximize|maximise> the window
Maximizes the currently active browser window to fill the entire screen area.
I <maximize|maximise> the window
I resize the window to width <w> and height <h>
Resizes the currently active browser window to the given dimensions.
I resize the window to width <w> and height <h>
I send "<keys>"
Sends a sequence of keys to the browser (for emulating keyboard shortcuts).
I send "<keys>"
Where
<keys>is a,or+(since v2.53.0) separated list of keys to send.- Keys can be single keyboard characters or any supported key constants
- Note: Keys behave differently on different platforms
Example
When I navigate to "https://google.com"
And I send "COMMAND+t"
I set the window position to x <x> and y <y>
Positions the currently active browser window to the given co-ordinates.
I set the window position to x <x> and y <y>
I send "<keys>"
Sends a sequence of keys to the browser (for emulating keyboard shortcuts).
I send "<keys>"
Where
<keys>is a,or+(since v2.53.0) separated list of keys to send.- Keys can be single keyboard characters or any supported key constants
- Note: Keys behave differently on different platforms
Example
When I navigate to "https://google.com"
And I send "COMMAND+t"