Switch

Provides functionality to switch between frames, windows, and tabs in the browser.

Classes

Switch

Methods

(async) toFrame(id)

Switches to a frame identified by its ID.
Parameters:
NameTypeDescription
idstring | numberThe ID of the frame.
Throws:
Throws an error if switching to the frame fails.
Type
Error

(async) toFrameBySelector(selector)

Switches to a frame identified by a CSS selector.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the frame element.
Throws:
Throws an error if the frame is not found or switching fails.
Type
Error

(async) toFrameByXpath(xpath)

Switches to a frame identified by an XPath.
Parameters:
NameTypeDescription
xpathstringThe XPath of the frame element.
Throws:
Throws an error if the frame is not found or switching fails.
Type
Error

(async) toNewTab(urlopt)

Opens a new tab and optionally navigates to a URL.
Parameters:
NameTypeAttributesDescription
urlstring<optional>
Optional URL to navigate to in the new tab.
Throws:
Throws an error if opening a new tab fails.
Type
Error

(async) toNewWindow(urlopt)

Opens a new window and optionally navigates to a URL.
Parameters:
NameTypeAttributesDescription
urlstring<optional>
Optional URL to navigate to in the new window.
Throws:
Throws an error if opening a new window fails.
Type
Error

(async) toParentFrame()

Switches to the parent frame of the current frame.
Throws:
Throws an error if switching to the parent frame fails.
Type
Error

(async) toWindow(name)

Switches to a window identified by its name.
Parameters:
NameTypeDescription
namestringThe name of the window.
Throws:
Throws an error if switching to the window fails.
Type
Error