Create a new session with the given Capabilities. The returned session becomes the "current session" for this action.
Note: if you're using runSession to run your WebDriver commands, you don't need to call this explicitly.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05
Modulewebdriver-0.12.0.1Haskell2010
This module exports basic WD actions that can be used to interact with a browser session.
Create a new session with the given Capabilities. The returned session becomes the "current session" for this action.
Note: if you're using runSession to run your WebDriver commands, you don't need to call this explicitly.
Close the current session and the browser associated with it.
Retrieve a list of active sessions and their Capabilities.
Get the actual server-side Capabilities of the current session.
Opens a new page by the given URL.
Navigate forward in the browser history.
Navigate backward in the browser history.
Refresh the current page
Gets the URL of the current page.
Get the current page source
Get the title of the current page.
Save a screenshot to a particular location
Grab a screenshot of the current page as a PNG image
Grab a screenshot as a base-64 encoded PNG image. This is the protocol-defined format.
Sets the amount of time (ms) we implicitly wait when searching for elements.
Sets the amount of time (ms) we wait for an asynchronous script to return a result.
Sets the amount of time (ms) to wait for a page to finish loading before throwing a Timeout exception.
Eq ElementDefined in webdriver-0.12.0.1 · Test.WebDriver.Commands.InternalOrd ElementDefined in webdriver-0.12.0.1 · Test.WebDriver.Commands.InternalRead ElementDefined in webdriver-0.12.0.1 · Test.WebDriver.Commands.InternalShow ElementDefined in webdriver-0.12.0.1 · Test.WebDriver.Commands.InternalFromJSON ElementDefined in webdriver-0.12.0.1 · Test.WebDriver.Commands.InternalToJSON ElementDefined in webdriver-0.12.0.1 · Test.WebDriver.Commands.InternalSpecifies element(s) within a DOM tree using various selection methods.
Find an element on the page using the given element selector.
Find all elements on the page matching the given selector.
Search for an element using the given element as root.
Find all elements matching a selector, using the given element as root.
Click on an element.
Submit a form element. This may be applied to descendents of a form element as well.
Get all visible text within this element.
Send a sequence of keystrokes to an element. All modifier keys are released at the end of the function. Named constants for special modifier keys can be found in Test.WebDriver.Common.Keys
Similar to sendKeys, but doesn't implicitly release modifier keys afterwards. This allows you to combine modifiers with mouse clicks.
Clear a textarea or text input element's value.
Retrieve the value of an element's attribute
Retrieve the value of an element's computed CSS property
Retrieve an element's current position.
Retrieve an element's current size.
Determine if the element is selected.
Determine if the element is enabled.
Determine if the element is displayed.
Return the tag name of the given element.
Return the element that currently has focus.
Deprecated. This command does not work with Marionette (Firefox) driver, and is likely to be completely removed in Selenium 4
Describe the element. Returns a JSON object whose meaning is currently undefined by the WebDriver protocol.
Determines if two element identifiers refer to the same element.
Determines if two element identifiers refer to different elements.
Inject a snippet of Javascript into the page for execution in the context of the currently selected frame. The executed script is assumed to be synchronous and the result of evaluating the script is returned and converted to an instance of FromJSON.
The first parameter defines a sequence of arguments to pass to the javascript function. Arguments of type Element will be converted to the corresponding DOM element. Likewise, any elements in the script result will be returned to the client as Elements.
The second parameter defines the script itself in the form of a function body. The value returned by that function will be returned to the client. The function will be invoked with the provided argument list and the values may be accessed via the arguments object in the order specified.
When using executeJS, GHC might complain about an ambiguous type in situations where the result of the executeJS call is ignored/discard. Consider the following example:
jsExample = do
e <- findElem (ById "foo")
executeJS [] "someAction()"
return e
Because the result of the executeJS is discarded, GHC cannot resolve which instance of the fromJSON class to use when parsing the Selenium server response. In such cases, we can use the ignoreReturn helper function located in Test.WebDriver.JSON. ignoreReturn has no runtime effect; it simply helps the type system by expicitly providing a fromJSON instance to use.
import Test.WebDriver.JSON (ignoreReturn)
jsExample = do
e <- findElem (ById "foo")
ignoreReturn $ executeJS [] "someAction()"
return e
Executes a snippet of Javascript code asynchronously. This function works similarly to executeJS, except that the Javascript is passed a callback function as its final argument. The script should call this function to signal that it has finished executing, passing to it a value that will be returned as the result of asyncJS. A result of Nothing indicates that the Javascript function timed out (see setScriptTimeout)
An existential wrapper for any ToJSON instance. This allows us to pass parameters of many different types to Javascript code.
An opaque identifier for a browser window
Eq WindowHandleDefined in webdriver-0.12.0.1 · Test.WebDriver.Commands.InternalOrd WindowHandleDefined in webdriver-0.12.0.1 · Test.WebDriver.Commands.InternalRead WindowHandleDefined in webdriver-0.12.0.1 · Test.WebDriver.Commands.InternalShow WindowHandleDefined in webdriver-0.12.0.1 · Test.WebDriver.Commands.InternalFromJSON WindowHandleDefined in webdriver-0.12.0.1 · Test.WebDriver.Commands.InternalToJSON WindowHandleDefined in webdriver-0.12.0.1 · Test.WebDriver.Commands.InternalDefault WindowHandleDefined in webdriver-0.12.0.1 · Test.WebDriver.Commands.InternalA special WindowHandle that always refers to the currently focused window. This is also used by the Default instance.
Returns a handle to the currently focused window
Closes the given window
Returns a list of all windows available to the session
Maximizes the current window if not already maximized
Get the dimensions of the current window.
Set the dimensions of the current window.
Get the coordinates of the current window.
Set the coordinates of the current window.
Switch focus to the frame specified by the FrameSelector.
Specifies the frame used by focusFrame
WithIndex IntegerWithName Textfocus on a frame by name or ID
WithElement Elementfocus on a frame Element
DefaultFramefocus on the first frame, or the main document if iframes are used.
Eq FrameSelectorDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsRead FrameSelectorDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsShow FrameSelectorDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsToJSON FrameSelectorDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsCookies are delicious delicacies. When sending cookies to the server, a value of Nothing indicates that the server should use a default value. When receiving cookies from the server, a value of Nothing indicates that the server is unable to specify the value.
CookiecookName :: TextcookValue :: TextcookPath :: Maybe Textpath of this cookie. if Nothing, defaults to /
cookDomain :: Maybe Textdomain of this cookie. if Nothing, the current pages domain is used
cookSecure :: Maybe BoolIs this cookie secure?
cookExpiry :: Maybe DoubleExpiry date expressed as seconds since the Unix epoch Nothing indicates that the cookie never expires
Eq CookieDefined in webdriver-0.12.0.1 · Test.WebDriver.CookiesShow CookieDefined in webdriver-0.12.0.1 · Test.WebDriver.CookiesGeneric CookieDefined in webdriver-0.12.0.1 · Test.WebDriver.CookiesFromJSON CookieDefined in webdriver-0.12.0.1 · Test.WebDriver.CookiesToJSON CookieDefined in webdriver-0.12.0.1 · Test.WebDriver.Cookiestype Rep Cookie = D1 ('MetaData "Cookie"
"Test.WebDriver.Cookies"
"webdriver-0.12.0.1-KugJygux6Vm4pvqhwCzHkH"
'False) (C1 ('MetaCons "Cookie"
'PrefixI 'True) ((S1 ('MetaSel ('Just "cookName"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: (S1 ('MetaSel ('Just "cookValue"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "cookPath"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text)))) :*: (S1 ('MetaSel ('Just "cookDomain"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text)) :*: (S1 ('MetaSel ('Just "cookSecure"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Bool)) :*: S1 ('MetaSel ('Just "cookExpiry"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Double))))))Defined in webdriver-0.12.0.1 · Test.WebDriver.CookiesCreates a Cookie with only a name and value specified. All other fields are set to Nothing, which tells the server to use default values.
Retrieve all cookies visible to the current page.
Set a cookie. If the cookie path is not specified, it will default to "/". Likewise, if the domain is omitted, it will default to the current page's domain
Delete a cookie. This will do nothing is the cookie isn't visible to the current page.
Delete all visible cookies on the current page.
Get the text of an alert dialog.
Sends keystrokes to Javascript prompt() dialog.
Accepts the currently displayed alert dialog.
Dismisses the currently displayed alert dialog.
Moves the mouse to the given position relative to the active element.
Moves the mouse to the center of a given element.
Moves the mouse to the given position relative to the given element.
Click at the current mouse position with the given mouse button.
A mouse button
Bounded MouseButtonDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsEnum MouseButtonDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsEq MouseButtonDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsOrd MouseButtonDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsShow MouseButtonDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsFromJSON MouseButtonDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsToJSON MouseButtonDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsPress and hold the left mouse button down. Note that undefined behavior occurs if the next mouse command is not mouseUp.
Release the left mouse button.
Perform the given action with the left mouse button held down. The mouse is automatically released afterwards.
Double click at the current mouse location.
An HTML 5 storage type
Bounded WebStorageTypeDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsEnum WebStorageTypeDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsEq WebStorageTypeDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsOrd WebStorageTypeDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsShow WebStorageTypeDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsGet the current number of keys in a web storage area.
Get a list of all keys from a web storage area.
Delete all keys within a given web storage area.
Get the value associated with a key in the given web storage area. Unset keys result in empty strings, since the Web Storage spec makes no distinction between the empty string and an undefined value.
Set a key in the given web storage area.
Delete a key in the given web storage area.
Bounded ApplicationCacheStatusDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsEnum ApplicationCacheStatusDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsEq ApplicationCacheStatusDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsOrd ApplicationCacheStatusDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsRead ApplicationCacheStatusDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsShow ApplicationCacheStatusDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsFromJSON ApplicationCacheStatusDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsBounded OrientationDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsEnum OrientationDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsEq OrientationDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsOrd OrientationDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsShow OrientationDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsFromJSON OrientationDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsToJSON OrientationDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsGet the current screen orientation for rotatable display devices.
Set the current screen orientation for rotatable display devices.
Get the current geographical location of the device.
Set the current geographical location of the device.
Single tap on the touch screen at the given element's location.
Emulates pressing a finger down on the screen at the given location.
Emulates removing a finger from the screen at the given location.
Emulates moving a finger on the screen to the given location.
Emulate finger-based touch scroll. Use this function if you don't care where the scroll begins
Emulate finger-based touch scroll, starting from the given location relative to the given element.
Emulate a double click on a touch device.
Emulate a long click on a touch device.
Emulate a flick on the touch screen. The coordinates indicate x and y velocity, respectively. Use this function if you don't care where the flick starts.
touchFlickFrom Emulate a flick on the touch screen.
These functions allow you to upload a file to a remote server. Note that this operation isn't supported by all WebDriver servers, and the location where the file is stored is not standardized.
Uploads a file from the local filesystem by its file path.
uploadRawFile :: (HasCallStack, WebDriver wd)=> FilePathFile path to use with this bytestring.
-> IntegerModification time (in seconds since Unix epoch).
-> ByteStringThe file contents as a lazy ByteString
-> wd ()Uploads a raw bytestring with associated file info.
Lowest level interface to the file uploading mechanism. This allows you to specify the exact details of the zip entry sent across network.
Get information from the server as a JSON Object. For more information about this object see https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#status
Retrieve the log buffer for a given log type. The server-side log buffer is reset after each request.
Which log types are available is server defined, but the wire protocol lists these as common log types: client, driver, browser, server
Get a list of available log types.
A record that represents a single log entry.
Eq LogEntryDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsOrd LogEntryDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsRead LogEntryDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsShow LogEntryDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsFromJSON LogEntryDefined in webdriver-0.12.0.1 · Test.WebDriver.CommandsBounded LogLevelDefined in webdriver-0.12.0.1 · Test.WebDriver.CapabilitiesEnum LogLevelDefined in webdriver-0.12.0.1 · Test.WebDriver.CapabilitiesEq LogLevelDefined in webdriver-0.12.0.1 · Test.WebDriver.CapabilitiesOrd LogLevelDefined in webdriver-0.12.0.1 · Test.WebDriver.CapabilitiesRead LogLevelDefined in webdriver-0.12.0.1 · Test.WebDriver.CapabilitiesShow LogLevelDefined in webdriver-0.12.0.1 · Test.WebDriver.CapabilitiesFromJSON LogLevelDefined in webdriver-0.12.0.1 · Test.WebDriver.CapabilitiesToJSON LogLevelDefined in webdriver-0.12.0.1 · Test.WebDriver.CapabilitiesDefault LogLevelDefined in webdriver-0.12.0.1 · Test.WebDriver.Capabilities