justgook/elm-webdriver/1.0.0

NOTE: the latest version is 1.0.2

WebDriver.Step

Location Navigation

url : WithSession -> String -> Out ()

Load the URL of the browser.

getUrl : WithSession -> Out String

Get the url of current opened website.

Elements

element : WithSession -> Selector -> 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 -> Selector -> 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 -> 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 -> Out ()

Clear a TEXTAREA or text INPUT element’s value.

value : WithSession -> String -> Element -> 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 -> Selector -> Element -> Out Element

Search for an element on the page, starting from an element. The located element will be returned as a Element.

elementsInElement : WithSession -> Selector -> Element -> 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 -> Out 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 -> Out Bool

Determine if an element is currently enabled.

tagName : WithSession -> Element -> Out String

Get tag name of a DOM-element.

text : WithSession -> Element -> 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 -> Out String

Get an attribute from a DOM-element based attribute name. Returns a attribute value.

property : WithSession -> String -> Element -> Out String

Get the value of an element’s property.

css : WithSession -> String -> Element -> 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.

WithSession
-> Element
-> Out
{ height : Float
, width : Float
, x : Float
, y : 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 -> 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 -> 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.

History Navigation

back : WithSession -> Out ()

Navigate backwards in the browser history, if possible.

forward : WithSession -> Out ()

Navigate forwards in the browser history, if possible.

refresh : WithSession -> Out ()

Refresh the current page.

Window

title : WithSession -> Out String

Get the title of current opened website.

windowHandle : WithSession -> Out WindowHandle

Get handle with tabs in the browser.

windowHandles : WithSession -> Out (List WindowHandle)

Retrieve the list of all window handles available to the session.

window : WithSession -> WindowHandle -> 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.

WithSession
-> Out
{ height : Float
, width : Float
, x : Float
, y : 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.

WithSession
-> { height : Float
, width : Float
, x : Float
, y : Float
}
-> Out
{ height : Float
, width : Float
, x : Float
, y : 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 -> 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 -> 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.

WithSession
-> Out
{ height : Float
, width : Float
, x : Float
, y : 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 -> Out (List WindowHandle)

Close current window (and focus on an other window).

screenshot : WithSession -> Out String

Take a screenshot of the current viewport.

Alerts

alertAccept : WithSession -> Out ()

Accepts the currently displayed alert dialog. Usually, this is equivalent to clicking on the ‘OK’ button in the dialog.

alertDismiss : WithSession -> 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 -> Out String

Gets the text of the currently displayed JavaScript alert(), confirm(), or prompt() dialog.

promptText : WithSession -> String -> Out ()

Keystrokes to send to the prompt() dialog.

Inject a snippet of JavaScript

execute : WithSession -> String -> List Value -> Out 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 Value -> Out 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 ]

Frames / iFrames

frameParent : WithSession -> Out ()

Change focus to the parent context. If the current context is the top level browsing context, the context remains unchanged.

frame : WithSession -> 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.

Timeouts

getTimeouts : WithSession -> Out Timeouts
setTimeouts : WithSession -> Timeouts -> Out 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

cookies : WithSession -> Out (List Cookie)

Get All Cookies

deleteCookies : WithSession -> Out ()

Delete cookies visible to the current page.

deleteCookie : WithSession -> String -> Out ()

Delete cookie visible to the current page. By providing a cookie name.

addCookie : WithSession -> String -> String -> 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

actions : WithSession -> List Action -> Out ()

Actions are a very complex portion of the spec. Some preliminary understanding of concepts is useful:

  • tick: a slice of an action chain. Actions from different input sources can be executed simultaneously. These are first lined up from the first action. Every vertical “slice” across the different input sources’ action lists is a tick. A tick is not associated with any particular time value, and lasts as long as the longest action duration inside the tick.
  • input source: a representation of an input device like a keyboard, mouse, finger, or pen. There can be any number of input sources. Each one has its own id.
  • action: a behavior performed by an input source. Different types of input source have different types of possible actions

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:

  • type: String, one of pointer, key, or none
  • id: String, a unique id chosen to represent this input source for this and future actions
  • parameters: pointer-type input sources can also have a parameters property, which is an object with a pointerType key specifying either mouse, pen, or touch. If parameters is omitted, the pointerType is considered to be mouse.
  • actions: a list of action objects for this particular input source. An action object has different fields based on the kind of input device it belongs to (see also here)
release : WithSession -> 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.

Webdriver Host info

status : Host -> Out 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.

#Low level function

type alias Functions =
{ back : Step ()
, close : Step (List WindowHandle)
, forward : Step ()
, getTimeouts : Step Timeouts
, getUrl : Step String
, refresh : Step ()
, setTimeouts : Timeouts -> Step Timeouts
, status : Step Status
, title : Step String
, url : String -> Step ()
, windowHandle : Step WindowHandle
, windowHandles : Step (List WindowHandle)
, window : WindowHandle -> Step ()
, fullscreen : Step ()
, maximize : Step ()
, minimize :
Step
{ height : Float
, width : Float
, x : Float
, y : Float
}
, frameParent : Step ()
, frame : Value -> Step ()
, source : Step String
, element : Selector -> Step Element
, elements : Selector -> Step (List Element)
, attribute : String -> Element -> Step String
, css : String -> Element -> Step String
, enabled : Element -> Step Bool
, property : String -> Element -> Step String
, rect :
Element
-> Step
{ height : Float
, width : Float
, x : Float
, y : Float
}
, selected : Element -> Step Bool
, tagName : Element -> Step String
, text : Element -> Step String
, elementInElement : Selector -> Element -> Step Element
, elementsInElement : Selector -> Element -> Step (List Element)
, getWindowRect :
Step
{ height : Float
, width : Float
, x : Float
, y : Float
}
, setWindowRect :
{ height : Float
, width : Float
, x : Float
, y : Float
}
-> Step
{ height : Float
, width : Float
, x : Float
, y : Float
}
, clear : Element -> Step ()
, click : Element -> Step ()
, value : String -> Element -> Step ()
, execute : String -> List Value -> Step Value
, executeAsync : String -> List Value -> Step Value
, addCookie : String -> String -> Step ()
, cookie : String -> Step Cookie
, cookies : Step (List 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 Value -> Step Value
, executeAsync : String -> List Value -> Step Value
}
}

Functions that is passed to tests, with already created session

type alias Host =
{ url : String }

Configuration containing url to WebDriver host, used in

type alias WithSession =
WithSession

Url to WebDriver host and current browsing session used in most of step functins

functions : WithSession -> Functions
Host
-> Value
-> Request
{ sessionId : String
, value : 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 -> 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