url : WithSession -> String -> WebDriver.Internal.Value.Out ()
Load the URL of the browser.
getUrl : WithSession -> WebDriver.Internal.Value.Out String
Get the url of current opened website.
element : WithSession -> Element.Selector -> WebDriver.Internal.Value.Out Element
Search for an element on the page, starting from the document root.
The located element will be returned as a Element
.
elements : WithSession -> Element.Selector -> WebDriver.Internal.Value.Out (List Element)
Search for multiple elements on the page, starting from the document root.
The located elements will be returned as a List Element
.
Elements should be returned in the order located in the DOM.
click : WithSession -> Element -> WebDriver.Internal.Value.Out ()
The Element Click command scrolls into view the element if it is not already pointer-interactable, and clicks its in-view center point.
If the element’s center point is obscured by another element, an element click intercepted error is returned. If the element is outside the viewport, an element not interactable error is returned.
Other input way (touch events, mouse up/down ...) can be done by actions
clear : WithSession -> Element -> WebDriver.Internal.Value.Out ()
Clear a TEXTAREA
or text INPUT
element’s value.
value : WithSession -> String -> Element -> WebDriver.Internal.Value.Out ()
Send a sequence of key strokes to an element.
You can also use unicode characters like Left arrow
or Backspace
(keys
)
WebdriverIO will take care of translating them into unicode characters.
You’ll find all supported characters here. To do that, the value has to correspond to a key from the table.
elementInElement : WithSession -> Element.Selector -> Element -> WebDriver.Internal.Value.Out Element
Search for an element on the page, starting from an element.
The located element will be returned as a Element
.
elementsInElement : WithSession -> Element.Selector -> Element -> WebDriver.Internal.Value.Out (List Element)
Search for multiple elements on the page, starting from an element.
The located elements will be returned as a List Element
.
Elements should be returned in the order located in the DOM.
selected : WithSession -> Element -> WebDriver.Internal.Value.Out Basics.Bool
The Is Element Selected command determines if the referenced element is selected or not. This operation only makes sense on input elements of the Checkbox- and Radio Button states, or on option elements.
enabled : WithSession -> Element -> WebDriver.Internal.Value.Out Basics.Bool
Determine if an element is currently enabled.
tagName : WithSession -> Element -> WebDriver.Internal.Value.Out String
Get tag name of a DOM-element.
text : WithSession -> Element -> WebDriver.Internal.Value.Out String
Get the text content from a DOM-elemen.
Make sure the element you want to request the text from is interactable
otherwise you will get an empty string as return value.
If the element is disabled or not visible and you still want to receive the text content use getHTML
(TODO) as a workaround.
attribute : WithSession -> String -> Element -> WebDriver.Internal.Value.Out String
Get an attribute from a DOM-element based attribute name. Returns a attribute value.
property : WithSession -> String -> Element -> WebDriver.Internal.Value.Out String
Get the value of an element’s property.
css : WithSession -> String -> Element -> WebDriver.Internal.Value.Out String
Get a css property from a DOM-element. The return value is not formatted.
Note that shorthand CSS properties (e.g. background, font, border, margin, padding, list-style, outline, pause, cue) are not returned, in accordance with the DOM CSS2 specification - you should directly access the longhand properties (e.g. background-color) to access the desired values.
rect : WithSession -> Element -> WebDriver.Internal.Value.Out { height : Basics.Float, width : Basics.Float, x : Basics.Float, y : Basics.Float }
The Get Element Rect command returns the dimensions and coordinates of the given web element.
The returned value is a record with x
, y
, width
and height
properties.
Note: this command was recently added to the official Webdriver protocol and might not be working with current Selenium driver.
elementScreenshot : WithSession -> Element -> WebDriver.Internal.Value.Out String
The Take Element Screenshot command takes a screenshot of the visible region encompassed by the bounding rectangle of an element. If given a parameter argument scroll that evaluates to false, the element will not be scrolled into view.
source : WithSession -> WebDriver.Internal.Value.Out String
Get source code of the page. This command won’t work in mobile environments for native apps. If you are running hybrid tests make sure that you are in the webview before calling this command.
back : WithSession -> WebDriver.Internal.Value.Out ()
Navigate backwards in the browser history, if possible.
forward : WithSession -> WebDriver.Internal.Value.Out ()
Navigate forwards in the browser history, if possible.
refresh : WithSession -> WebDriver.Internal.Value.Out ()
Refresh the current page.
title : WithSession -> WebDriver.Internal.Value.Out String
Get the title of current opened website.
windowHandle : WithSession -> WebDriver.Internal.Value.Out WebDriver.Internal.Value.WindowHandle
Get handle with tabs in the browser.
windowHandles : WithSession -> WebDriver.Internal.Value.Out (List WebDriver.Internal.Value.WindowHandle)
Retrieve the list of all window handles available to the session.
window : WithSession -> WebDriver.Internal.Value.WindowHandle -> WebDriver.Internal.Value.Out ()
Switching window will select the current top-level browsing context used as the target for all subsequent commands. In a tabbed browser, this will typically make the tab containing the browsing context the selected tab.
getWindowRect : WithSession -> WebDriver.Internal.Value.Out { height : Basics.Float, width : Basics.Float, x : Basics.Float, y : Basics.Float }
The Get Window Rect command returns the size and position on the screen of the operating system window corresponding to the current top-level browsing context.
setWindowRect : WithSession -> { height : Basics.Float, width : Basics.Float, x : Basics.Float, y : Basics.Float } -> WebDriver.Internal.Value.Out { height : Basics.Float, width : Basics.Float, x : Basics.Float, y : Basics.Float }
The Set Window Rect command alters the size and the position of the operating system window corresponding to the current top-level browsing context.
fullscreen : WithSession -> WebDriver.Internal.Value.Out ()
The Fullscreen Window command invokes the window manager-specific “full screen” operation, if any, on the window containing the current top-level browsing context. This typically increases the window to the size of the physical display and can hide browser UI elements such as toolbars.
Note: this command was recently added to the official Webdriver protocol and might not be working with current Selenium driver.
maximize : WithSession -> WebDriver.Internal.Value.Out ()
The Maximize Window command invokes the window manager-specific “maximize” operation, if any, on the window containing the current top-level browsing context. This typically increases the window to the maximum available size without going full-screen.
minimize : WithSession -> WebDriver.Internal.Value.Out { height : Basics.Float, width : Basics.Float, x : Basics.Float, y : Basics.Float }
The Minimize Window command invokes the window manager-specific “minimize” operation, if any, on the window containing the current top-level browsing context. This typically hides the window in the system tray.
close : WithSession -> WebDriver.Internal.Value.Out (List WebDriver.Internal.Value.WindowHandle)
Close current window (and focus on an other window).
screenshot : WithSession -> WebDriver.Internal.Value.Out String
Take a screenshot of the current viewport.
alertAccept : WithSession -> WebDriver.Internal.Value.Out ()
Accepts the currently displayed alert dialog. Usually, this is equivalent to clicking on the ‘OK’ button in the dialog.
alertDismiss : WithSession -> WebDriver.Internal.Value.Out ()
Dismisses the currently displayed alert dialog. For confirm() and prompt() dialogs, this is equivalent to clicking the ‘Cancel’ button. For alert() dialogs, this is equivalent to clicking the ‘OK’ button.
alertText : WithSession -> WebDriver.Internal.Value.Out String
Gets the text of the currently displayed JavaScript alert(), confirm(), or prompt() dialog.
promptText : WithSession -> String -> WebDriver.Internal.Value.Out ()
Keystrokes to send to the prompt() dialog.
execute : WithSession -> String -> List Json.Encode.Value -> WebDriver.Internal.Value.Out Json.Encode.Value
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 to the client.
The script argument defines the script to execute 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 args List Json.Value
and the values may be accessed via the arguments object in the order specified.
Arguments may be any JSON-primitive, array, or JSON object.
execute
settings
"alert(arguments[arguments.length - 1])"
[ Json.string "4123412", Json.int 3 ]
executeAsync : WithSession -> String -> List Json.Encode.Value -> WebDriver.Internal.Value.Out Json.Encode.Value
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 asynchronous and must signal that is done by invoking the provided callback, which is always provided as the final argument to the function. The value to this callback will be returned to the client.
Asynchronous script commands may not span page loads. If an unload event is fired while waiting for a script result, an error should be returned to the client.
The script argument defines the script to execute in the form of a function body.
The function will be invoked with the provided args List Json.Value
and the values may be accessed via the arguments object in the order specified.
The final argument will always be a callback function that must be invoked to signal that the script has finished.
Arguments may be any JSON-primitive, array, or JSON object.
let
script =
"""
const {a,b,c,d,done} = arguments;
setTimeout(function() {
done(a + b + c + d);
}, 3000);"""
in
executeAsync
settings
script
[ Json.string "4123412", Json.int 3 ]
frameParent : WithSession -> WebDriver.Internal.Value.Out ()
Change focus to the parent context. If the current context is the top level browsing context, the context remains unchanged.
frame : WithSession -> Json.Encode.Value -> WebDriver.Internal.Value.Out ()
TODO improve arguments
Change focus to another frame on the page. If the frame id is null, the server should switch to the page’s default content.
getTimeouts : WithSession -> WebDriver.Internal.Value.Out WebDriver.Internal.Value.Timeouts.Timeouts
setTimeouts : WithSession -> WebDriver.Internal.Value.Timeouts.Timeouts -> WebDriver.Internal.Value.Out WebDriver.Internal.Value.Timeouts.Timeouts
script
- session script timeout - Determines when to interrupt a script that is being evaluated.pageLoad
- session page load timeout - Provides the timeout limit used to interrupt navigation of the browsing context.implicit
- session implicit wait timeout - Gives the timeout of when to abort locating an element.Configure the amount of time that a particular type of operation can execute for before they are aborted and a Timeout error is returned to the client.
cookies : WithSession -> WebDriver.Internal.Value.Out (List WebDriver.Internal.Value.Cookie)
Get All Cookies
cookie : { a | sessionId : String, url : String } -> String -> WebDriver.Internal.Value.Out WebDriver.Internal.Value.Cookie
Get Named Cookie
deleteCookies : WithSession -> WebDriver.Internal.Value.Out ()
Delete cookies visible to the current page.
deleteCookie : WithSession -> String -> WebDriver.Internal.Value.Out ()
Delete cookie visible to the current page. By providing a cookie name.
addCookie : WithSession -> String -> String -> WebDriver.Internal.Value.Out ()
Sets a cookie for current page. Make sure you are on the page that should receive the cookie. You can’t set a cookie for an arbitrary page without being on that page.
actions : WithSession -> List Action -> WebDriver.Internal.Value.Out ()
Actions are a very complex portion of the spec. Some preliminary understanding of concepts is useful:
The command takes a list of input source actions. In other words, a list of objects, each of which represents an input source and its associated actions. Each input source must have the following properties:
here
)release : WithSession -> WebDriver.Internal.Value.Out ()
The Release Actions command is used to release all the keys and pointer buttons that are currently depressed. This causes events to be fired as if the state was released by an explicit series of actions. It also clears all the internal state of the virtual devices.
status : Host -> WebDriver.Internal.Value.Out WebDriver.Internal.Value.Status.Status
Query the server’s current status. The server should respond with a general “HTTP 200 OK” response if it is alive and accepting commands. The response body should be a JSON object describing the state of the server. All server implementations should return two basic objects describing the server’s current platform and when the server was built. All fields are optional; if omitted, the client should assume the value is unknown. Furthermore, server implementations may include additional fields not listed here.
{ back : Step ()
, close : Step (List WebDriver.Internal.Value.WindowHandle)
, forward : Step ()
, getTimeouts : Step WebDriver.Internal.Value.Timeouts.Timeouts
, getUrl : Step String
, refresh : Step ()
, setTimeouts : WebDriver.Internal.Value.Timeouts.Timeouts -> Step WebDriver.Internal.Value.Timeouts.Timeouts
, status : Step WebDriver.Internal.Value.Status.Status
, title : Step String
, url : String -> Step ()
, windowHandle : Step WebDriver.Internal.Value.WindowHandle
, windowHandles : Step (List WebDriver.Internal.Value.WindowHandle)
, window : WebDriver.Internal.Value.WindowHandle -> Step ()
, fullscreen : Step ()
, maximize : Step ()
, minimize : Step { height : Basics.Float
, width : Basics.Float
, x : Basics.Float
, y : Basics.Float }
, frameParent : Step ()
, frame : Json.Encode.Value -> Step ()
, source : Step String
, element : Element.Selector -> Step Element
, elements : Element.Selector -> Step (List Element)
, attribute : String -> Element -> Step String
, css : String -> Element -> Step String
, enabled : Element -> Step Basics.Bool
, property : String -> Element -> Step String
, rect : Element -> Step { height : Basics.Float
, width : Basics.Float
, x : Basics.Float
, y : Basics.Float }
, selected : Element -> Step Basics.Bool
, tagName : Element -> Step String
, text : Element -> Step String
, elementInElement : Element.Selector -> Element -> Step Element
, elementsInElement : Element.Selector -> Element -> Step (List Element)
, getWindowRect : Step { height : Basics.Float
, width : Basics.Float
, x : Basics.Float
, y : Basics.Float }
, setWindowRect : { height : Basics.Float
, width : Basics.Float
, x : Basics.Float
, y : Basics.Float } -> Step { height : Basics.Float
, width : Basics.Float
, x : Basics.Float
, y : Basics.Float }
, clear : Element -> Step ()
, click : Element -> Step ()
, value : String -> Element -> Step ()
, execute : String -> List Json.Encode.Value -> Step Json.Encode.Value
, executeAsync : String -> List Json.Encode.Value -> Step Json.Encode.Value
, addCookie : String -> String -> Step ()
, cookie : String -> Step WebDriver.Internal.Value.Cookie
, cookies : Step (List WebDriver.Internal.Value.Cookie)
, deleteCookie : String -> Step ()
, deleteCookies : Step ()
, alertAccept : Step ()
, alertDismiss : Step ()
, alertText : Step String
, promptText : String -> Step ()
, elementScreenshot : Element -> Step String
, screenshot : Step String
, actions : List Action -> Step ()
, release : Step ()
, selenium : { execute : String -> List Json.Encode.Value -> Step Json.Encode.Value
, executeAsync : String -> List Json.Encode.Value -> Step Json.Encode.Value }
}
Functions that is passed to tests, with already created session
{ url : String }
Configuration containing url to WebDriver host, used in
WebDriver.Internal.Value.WithSession
Url to WebDriver host and current browsing session used in most of step functins
functions : WithSession -> Functions
sessionStart : Host -> Json.Encode.Value -> Http.Request { sessionId : String, value : Json.Encode.Value }
Creates a new session with the desired capabilities. and task result in info of created session as Json.Value
Note: Most of cases you don't need it runner will create session for you and stop, after test is done
sessionStop : WithSession -> WebDriver.Internal.Value.Out ()
Stops session created with sessionStart
functon
Note: Most of cases you don't need it runner will crates session for you and stop, after test is done