WebDriver.Protocol
Implements the HTTP JSON wire protocol for WebDriver. This is the internal protocol and is supposed to be called via the WebDriver session server rather than directly.
https://code.google.com/p/selenium/wiki/JsonWireProtocol
All these calls take a WebDriver.Config record as a first parameter. The other parameters depend on the specific protocol call.
All successful calls return {:ok, response} where response is a WebDriver.Protocol.Response record.
Failed calls return {:error, status, body} where the status is the HTTP status returned and the body is the raw body of the returned response.
A WebDriver response consists of a session id, status and return value. The session id is an opaque string provided by the server. The status can be one of the WebDriver status codes: https://code.google.com/p/selenium/wiki/JsonWireProtocol#/status
The value varies according to the call made.
The Response struct defined here also appends the request details to that response.
Summary
Functions
Accepts the currently displayed alert dialog https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/accept_alert
Get the element on the page that currently has focus. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/active
Gets the text of the currently displayed JavaScript alert(), confirm(), or prompt() dialog. https://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/alert_text
Sends keystrokes to a Javascript prompt() dialog.
Returns the value of the given element’s attribute. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/attribute/:name
Navigate back to the previous page. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/back
Clears the specified form field or textarea element. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/clear
Click on the specified element. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/click
Closes the current window. https://code.google.com/p/selenium/wiki/JsonWireProtocol#DELETE_/session/:sessionId/window
Retreive all the cookies associated with the current page. https://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/cookie
Get the computed value of an element’s CSS property. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/css/:propertyName
Delete the cookie with the given name. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/cookie/:name
Delete all cookies for the current page. https://code.google.com/p/selenium/wiki/JsonWireProtocol#DELETE_/session/:sessionId/cookie
Dismisses the currently displayed alert dialog https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/dismiss_alert
Returns a boolean denoting if the element is currently visible. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/displayed
Retreive an element from the page using the specified search strategy. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element
Parameters [using: "class name" | "css selector" | "id" | "name" | "link text" | "partial link test" | "tag name" | "xpath", value: string]
Retreive an element from the page starting from the specified element using the specified search strategy. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/element
Parameters [using: "class name" | "css selector" | "id" | "name" | "link text" | "partial link test" | "tag name" | "xpath", value: string]
Get the element identified by the id. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id
Retreive all elements from the page using the specified search strategy. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element
Parameters [using: "class name" | "css selector" | "id" | "name" | "link text" | "partial link test" | "tag name" | "xpath", value: string]
Retreive all elements starting from the specified element using the specified search strategy. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/elements
Parameters [using: "class name" | "css selector" | "id" | "name" | "link text" | "partial link test" | "tag name" | "xpath", value: string]
Returns a boolean denoting if the element is enabled or not. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/enabled
Determine if two element ids refer to the same DOM element. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/equals/:other
Execute Javascript on the page. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/execute
Parameters: [script: string, args: list]
## Example:
iex> config = WebDriver.Config[host: "localhost", port: 8080]
iex> sid = WebDriver.Protocol.start_session(config, [desiredCapabilities: []]).session_id
iex> resp = WebDriver.Protocol.execute(config, sid, [script: "return 1+1", args: []])
iex> resp.value
2
Execute asynchronous Javascript on the page. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/execute_async
Parameters: [script: string, args: list]
Navigate forward to the next page. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/forward
Change the frame that has focus in the current window. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/frame
Parameters: [id: string | number | :null | WebElement]
Retreive the current geo location of the browser. https://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/location
Set the current geo location of the browser. https://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/location
Parameters: [lattitude: number, longitude: number, altitude: number]
Send a list of keystrokes to the currently active element. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/keys
Parameters: [value: Array
Returns the current location of the specified element https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/location
Determine an element’s location once it has been scrolled into view. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/location_in_view
Maximise the specified window. Use “current” or simply do not specify a handle to maximise the current window.
Send a mouse button down event. The parameter is a number indicating which button is to be pressed. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/buttondown Defaults to the left button if not specified.
Parameters: [button: 1(left) | 2(middle) | 3(right)]
Send a mouse button up event. Every button down event needs to be followed by this. The parameter is a number indicating which button is to be raised. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/buttondown Defaults to the left button if not specified.
Parameters: [button: 1(left) | 2(middle) | 3(right)]
Send a mouse click at the position of the last move_to command. The parameter is a number indicating which button is to be clicked. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/click Defaults to the left button if not specified.
Parameters: [button: 1(left) | 2(middle) | 3(right)]
Send a double click at the position of the last move_to command. The parameter is a number indicating which button is to be double clicked. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/click Defaults to the left button if not specified.
Parameters: [button: 1(left) | 2(middle) | 3(right)]
Move the mouse by an offset to the specified element. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/moveto
Parameters: [element: element_id, offsetx: number, offsety: number]
Get the name of the specified element. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/name
Get the current browser screen orientation. https://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/orientation
Set the current browser screen orientation https://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/orientation
Refresh the current page. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/refresh
Retreive a screenshot of the current page. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/screenshot
Returns a base64 encoded PNG image.
Returns a boolean denoting if the element is selected or not. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/selected
Retreive information about a session. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId
Gets a list of all sessions on the server. https://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/sessions
Set the script timeout for the session. https://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/timeouts/async_script
Parameters: [ms: number]
Set a cookie for the current page. https://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/cookie
Parameters: [cookie: object]
Set the implicit wait timeout for the session. https://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/timeouts/implicit_wait
Parameters: [ms: number]
Set timeouts on the server. Parameters must include the type of timeout and the length in milliseconds (ms). Valid types are “script” and “implicit”
Parameters [type: "script"|"implicit", ms: number]
Get the size of an element in pixels. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/size
Retreive the curent page source. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/source
Creates a new session on the server. https://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session
Parameters: [desiredCapabilities: WebDriver.Protocol.Capabilities] ## Examples:
iex> config = WebDriver.Config[host: "localhost", port: 8080]
iex> resp = WebDriver.Protocol.start_session(config, [desiredCapabilities: []])
iex> resp.session_id
"370f0750-e1dd-11e2-af7a-8562953caa56"
Returns the status of the WebDriver server. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/status
## Examples:
iex> config = WebDriver.Config[host: "localhost", port: 8080]
iex> resp = WebDriver.Protocol.status(config)
iex> resp.status
0
iex> resp.session_id
:null
iex> resp.value
[{"build",[{"version","1.0.3"}]},{"os",[{"name","mac"},{"version","10.8 (Mountain Lion)"},{"arch","32bit"}]}]
Stop the current session on the server. https://code.google.com/p/selenium/wiki/JsonWireProtocol#DELETE_/session/:sessionId
Submit a FORM element. May be applied to any descendent of a FORM element. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/submit
Retreives the visible text of the element. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/text
Retreive the current page title. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/title
Finger tap on an element on the screen. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/touch/click
Parameters: [element: element_id] The element to tap on.
Double finger tap on an element on the screen. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/touch/doubleclick
Parameters: [element: element_id] The element to tap on.
Finger down on the screen. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/touch/down
Parameters: [x: number, y: number]
Flick on the touch screen using finger motion events. The element, xoffset and yoffset parameters are optional if you do not care where the flick starts. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/touch/flick
Parameters: [element: element_id, xoffset: number, yoffset: number, xSpeed: number, ySpeed: number]
Long finger tap on an element on the screen. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/touch/longclick
Parameters: [element: element_id] The element to tap on.
Move the finger on the screen to the specified position. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/touch/move
Parameters: [x: number, y: number]
Scroll on the touch screen using finger based motion events. The element parameter is optional and can be left out if you dont care where the scroll starts. https://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_session/:sessionId/touch/scroll
Parameters [element: element, x: number, y:number]
Finger up on the screen https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/touch/up
Parameters: [x: number, y: number]
Retreive the URL of the current page. https://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/url
Navigate to a new URL. https://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/url
Parameters: [url: new_url]
Send a list of keystrokes to the specified element. https://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/element/:id/value
Parameters: [value: Array
Change the focus to another window. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/window
The window may be specified by the server assigned window handle or the value of it’s name attribute.
Parameters: [name: string]
Get the current window handle for the session. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/window_handle
Retreive a list of window handles available for the session. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/window_handles
Retreive the window position for the specified window or if not specified, the current window. https://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/window/:windowHandle/position
Set the window position for the specified window if parameters are sent. Set window handle to “current” to set the current window position.
Parameters: [x: number, y: number]
Retreive the window size. If a window handle is not specified it retreives the current window.
When the parameters are specified this will change the window size. https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/window/:windowHandle/size
Parameters: [height: number, width: number]