Safe Haskell | None |
---|---|
Language | Haskell98 |
This module exports basic WD actions that can be used to interact with a browser session.
- createSession :: WebDriver wd => Capabilities -> wd WDSession
- closeSession :: WebDriver wd => wd ()
- sessions :: WebDriver wd => wd [(SessionId, Capabilities)]
- getCaps :: WebDriver wd => wd Capabilities
- openPage :: WebDriver wd => String -> wd ()
- forward :: WebDriver wd => wd ()
- back :: WebDriver wd => wd ()
- refresh :: WebDriver wd => wd ()
- getCurrentURL :: WebDriver wd => wd String
- getSource :: WebDriver wd => wd Text
- getTitle :: WebDriver wd => wd Text
- screenshot :: WebDriver wd => wd ByteString
- screenshotBase64 :: WebDriver wd => wd ByteString
- setImplicitWait :: WebDriver wd => Integer -> wd ()
- setScriptTimeout :: WebDriver wd => Integer -> wd ()
- setPageLoadTimeout :: WebDriver wd => Integer -> wd ()
- newtype Element = Element Text
- data Selector
- findElem :: WebDriver wd => Selector -> wd Element
- findElems :: WebDriver wd => Selector -> wd [Element]
- findElemFrom :: WebDriver wd => Element -> Selector -> wd Element
- findElemsFrom :: WebDriver wd => Element -> Selector -> wd [Element]
- click :: WebDriver wd => Element -> wd ()
- submit :: WebDriver wd => Element -> wd ()
- getText :: WebDriver wd => Element -> wd Text
- sendKeys :: WebDriver wd => Text -> Element -> wd ()
- sendRawKeys :: WebDriver wd => Text -> Element -> wd ()
- clearInput :: WebDriver wd => Element -> wd ()
- attr :: WebDriver wd => Element -> Text -> wd (Maybe Text)
- cssProp :: WebDriver wd => Element -> Text -> wd (Maybe Text)
- elemPos :: WebDriver wd => Element -> wd (Int, Int)
- elemSize :: WebDriver wd => Element -> wd (Word, Word)
- isSelected :: WebDriver wd => Element -> wd Bool
- isEnabled :: WebDriver wd => Element -> wd Bool
- isDisplayed :: WebDriver wd => Element -> wd Bool
- tagName :: WebDriver wd => Element -> wd Text
- activeElem :: WebDriver wd => wd Element
- elemInfo :: WebDriver wd => Element -> wd Value
- (<==>) :: WebDriver wd => Element -> Element -> wd Bool
- (</=>) :: WebDriver wd => Element -> Element -> wd Bool
- executeJS :: (WebDriver wd, FromJSON a) => [JSArg] -> Text -> wd a
- asyncJS :: (WebDriver wd, FromJSON a) => [JSArg] -> Text -> wd (Maybe a)
- data JSArg = forall a . ToJSON a => JSArg a
- newtype WindowHandle = WindowHandle Text
- currentWindow :: WindowHandle
- getCurrentWindow :: WebDriver wd => wd WindowHandle
- closeWindow :: WebDriver wd => WindowHandle -> wd ()
- windows :: WebDriver wd => wd [WindowHandle]
- focusWindow :: WebDriver wd => WindowHandle -> wd ()
- maximize :: WebDriver wd => wd ()
- getWindowSize :: WebDriver wd => wd (Word, Word)
- setWindowSize :: WebDriver wd => (Word, Word) -> wd ()
- getWindowPos :: WebDriver wd => wd (Int, Int)
- setWindowPos :: WebDriver wd => (Int, Int) -> wd ()
- focusFrame :: WebDriver wd => FrameSelector -> wd ()
- data FrameSelector
- data Cookie = Cookie {}
- mkCookie :: Text -> Text -> Cookie
- cookies :: WebDriver wd => wd [Cookie]
- setCookie :: WebDriver wd => Cookie -> wd ()
- deleteCookie :: WebDriver wd => Cookie -> wd ()
- deleteVisibleCookies :: WebDriver wd => wd ()
- deleteCookieByName :: WebDriver wd => Text -> wd ()
- getAlertText :: WebDriver wd => wd Text
- replyToAlert :: WebDriver wd => Text -> wd ()
- acceptAlert :: WebDriver wd => wd ()
- dismissAlert :: WebDriver wd => wd ()
- moveTo :: WebDriver wd => (Int, Int) -> wd ()
- moveToCenter :: WebDriver wd => Element -> wd ()
- moveToFrom :: WebDriver wd => (Int, Int) -> Element -> wd ()
- clickWith :: WebDriver wd => MouseButton -> wd ()
- data MouseButton
- mouseDown :: WebDriver wd => wd ()
- mouseUp :: WebDriver wd => wd ()
- withMouseDown :: WebDriver wd => wd a -> wd a
- doubleClick :: WebDriver wd => wd ()
- data WebStorageType
- storageSize :: WebDriver wd => WebStorageType -> wd Integer
- getAllKeys :: WebDriver wd => WebStorageType -> wd [Text]
- deleteAllKeys :: WebDriver wd => WebStorageType -> wd ()
- getKey :: WebDriver wd => WebStorageType -> Text -> wd Text
- setKey :: WebDriver wd => WebStorageType -> Text -> Text -> wd Text
- deleteKey :: WebDriver wd => WebStorageType -> Text -> wd ()
- data ApplicationCacheStatus
- getApplicationCacheStatus :: WebDriver wd => wd ApplicationCacheStatus
- data Orientation
- getOrientation :: WebDriver wd => wd Orientation
- setOrientation :: WebDriver wd => Orientation -> wd ()
- getLocation :: WebDriver wd => wd (Int, Int, Int)
- setLocation :: WebDriver wd => (Int, Int, Int) -> wd ()
- touchClick :: WebDriver wd => Element -> wd ()
- touchDown :: WebDriver wd => (Int, Int) -> wd ()
- touchUp :: WebDriver wd => (Int, Int) -> wd ()
- touchMove :: WebDriver wd => (Int, Int) -> wd ()
- touchScroll :: WebDriver wd => (Int, Int) -> wd ()
- touchScrollFrom :: WebDriver wd => (Int, Int) -> Element -> wd ()
- touchDoubleClick :: WebDriver wd => Element -> wd ()
- touchLongClick :: WebDriver wd => Element -> wd ()
- touchFlick :: WebDriver wd => (Int, Int) -> wd ()
- touchFlickFrom :: WebDriver wd => Int -> (Int, Int) -> Element -> wd ()
- availableIMEEngines :: WebDriver wd => wd [Text]
- activeIMEEngine :: WebDriver wd => wd Text
- checkIMEActive :: WebDriver wd => wd Bool
- activateIME :: WebDriver wd => Text -> wd ()
- deactivateIME :: WebDriver wd => wd ()
- uploadFile :: WebDriver wd => FilePath -> wd ()
- uploadRawFile :: WebDriver wd => FilePath -> Integer -> ByteString -> wd ()
- uploadZipEntry :: WebDriver wd => Entry -> wd ()
- serverStatus :: WebDriver wd => wd Value
- getLogs :: WebDriver wd => LogType -> wd [LogEntry]
- getLogTypes :: WebDriver wd => wd [LogType]
- type LogType = String
- data LogEntry = LogEntry {}
- data LogLevel
Sessions
createSession :: WebDriver wd => Capabilities -> wd WDSession Source
Create a new session with the given Capabilities
.
closeSession :: WebDriver wd => wd () Source
Close the current session and the browser associated with it.
sessions :: WebDriver wd => wd [(SessionId, Capabilities)] Source
Retrieve a list of active sessions and their Capabilities
.
getCaps :: WebDriver wd => wd Capabilities Source
Get the actual Capabilities
of the current session.
Browser interaction
Web navigation
Page info
getCurrentURL :: WebDriver wd => wd String Source
Gets the URL of the current page.
screenshot :: WebDriver wd => wd ByteString Source
Grab a screenshot of the current page as a PNG image
screenshotBase64 :: WebDriver wd => wd ByteString Source
Grab a screenshot as a base-64 encoded PNG image. This is the protocol-defined format.
Timeouts
setImplicitWait :: WebDriver wd => Integer -> wd () Source
Sets the amount of time we implicitly wait when searching for elements.
setScriptTimeout :: WebDriver wd => Integer -> wd () Source
Sets the amount of time we wait for an asynchronous script to return a result.
setPageLoadTimeout :: WebDriver wd => Integer -> wd () Source
Sets the amount of time to wait for a page to finish loading before throwing a Timeout
exception
Web elements
An opaque identifier for a web page element.
Specifies element(s) within a DOM tree using various selection methods.
Searching for elements
findElem :: WebDriver wd => Selector -> wd Element Source
Find an element on the page using the given element selector.
findElems :: WebDriver wd => Selector -> wd [Element] Source
Find all elements on the page matching the given selector.
findElemFrom :: WebDriver wd => Element -> Selector -> wd Element Source
Search for an element using the given element as root.
findElemsFrom :: WebDriver wd => Element -> Selector -> wd [Element] Source
Find all elements matching a selector, using the given element as root.
Interacting with elements
submit :: WebDriver wd => Element -> wd () Source
Submit a form element. This may be applied to descendents of a form element as well.
Sending key inputs to elements
sendKeys :: WebDriver wd => Text -> Element -> wd () Source
Send a sequence of keystrokes to an element. All modifier keys are released at the end of the function. For more information about modifier keys, see http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/value
sendRawKeys :: WebDriver wd => Text -> Element -> wd () Source
Similar to sendKeys, but doesn't implicitly release modifier keys afterwards. This allows you to combine modifiers with mouse clicks.
clearInput :: WebDriver wd => Element -> wd () Source
Clear a textarea or text input element's value.
Element information
attr :: WebDriver wd => Element -> Text -> wd (Maybe Text) Source
Retrieve the value of an element's attribute
cssProp :: WebDriver wd => Element -> Text -> wd (Maybe Text) Source
Retrieve the value of an element's computed CSS property
isSelected :: WebDriver wd => Element -> wd Bool Source
Determine if the element is selected.
isDisplayed :: WebDriver wd => Element -> wd Bool Source
Determine if the element is displayed.
activeElem :: WebDriver wd => wd Element Source
Return the element that currently has focus.
elemInfo :: WebDriver wd => Element -> wd Value Source
Describe the element. Returns a JSON object whose meaning is currently undefined by the WebDriver protocol.
Element equality
(<==>) :: WebDriver wd => Element -> Element -> wd Bool infix 4 Source
Determines if two element identifiers refer to the same element.
(</=>) :: WebDriver wd => Element -> Element -> wd Bool infix 4 Source
Determines if two element identifiers refer to different elements.
Javascript
executeJS :: (WebDriver wd, FromJSON a) => [JSArg] -> Text -> wd a Source
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 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.
asyncJS :: (WebDriver wd, FromJSON a) => [JSArg] -> Text -> wd (Maybe a) Source
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.
Windows
newtype WindowHandle Source
An opaque identifier for a browser window
currentWindow :: WindowHandle Source
A special WindowHandle
that always refers to the currently focused window.
This is also used by the Default
instance.
getCurrentWindow :: WebDriver wd => wd WindowHandle Source
Returns a handle to the currently focused window
closeWindow :: WebDriver wd => WindowHandle -> wd () Source
Closes the given window
windows :: WebDriver wd => wd [WindowHandle] Source
Returns a list of all windows available to the session
focusWindow :: WebDriver wd => WindowHandle -> wd () Source
getWindowSize :: WebDriver wd => wd (Word, Word) Source
Get the dimensions of the current window.
setWindowSize :: WebDriver wd => (Word, Word) -> wd () Source
Set the dimensions of the current window.
getWindowPos :: WebDriver wd => wd (Int, Int) Source
Get the coordinates of the current window.
setWindowPos :: WebDriver wd => (Int, Int) -> wd () Source
Set the coordinates of the current window.
Focusing on frames
focusFrame :: WebDriver wd => FrameSelector -> wd () Source
Switch focus to the frame specified by the FrameSelector.
data FrameSelector Source
Specifies the frame used by focusFrame
WithIndex Integer | |
WithName Text | focus on a frame by name or ID |
WithElement Element | focus on a frame |
DefaultFrame | focus on the first frame, or the main document if iframes are used. |
Cookies
Cookies 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.
Cookie | |
|
mkCookie :: Text -> Text -> Cookie Source
Creates a Cookie with only a name and value specified. All other fields are set to Nothing, which tells the server to use default values.
setCookie :: WebDriver wd => Cookie -> wd () Source
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
deleteCookie :: WebDriver wd => Cookie -> wd () Source
Delete a cookie. This will do nothing is the cookie isn't visible to the current page.
deleteVisibleCookies :: WebDriver wd => wd () Source
Delete all visible cookies on the current page.
deleteCookieByName :: WebDriver wd => Text -> wd () Source
Alerts
getAlertText :: WebDriver wd => wd Text Source
Get the text of an alert dialog.
replyToAlert :: WebDriver wd => Text -> wd () Source
Sends keystrokes to Javascript prompt() dialog.
acceptAlert :: WebDriver wd => wd () Source
Accepts the currently displayed alert dialog.
dismissAlert :: WebDriver wd => wd () Source
Dismisses the currently displayed alert dialog.
Mouse gestures
moveTo :: WebDriver wd => (Int, Int) -> wd () Source
Moves the mouse to the given position relative to the active element.
moveToCenter :: WebDriver wd => Element -> wd () Source
Moves the mouse to the center of a given element.
moveToFrom :: WebDriver wd => (Int, Int) -> Element -> wd () Source
Moves the mouse to the given position relative to the given element.
clickWith :: WebDriver wd => MouseButton -> wd () Source
Click at the current mouse position with the given mouse button.
data MouseButton Source
A mouse button
mouseDown :: WebDriver wd => wd () Source
Press and hold the left mouse button down. Note that undefined behavior occurs if the next mouse command is not mouseUp.
withMouseDown :: WebDriver wd => wd a -> wd a Source
Perform the given action with the left mouse button held down. The mouse is automatically released afterwards.
doubleClick :: WebDriver wd => wd () Source
Double click at the current mouse location.
HTML 5 Web Storage
data WebStorageType Source
An HTML 5 storage type
storageSize :: WebDriver wd => WebStorageType -> wd Integer Source
Get the current number of keys in a web storage area.
getAllKeys :: WebDriver wd => WebStorageType -> wd [Text] Source
Get a list of all keys from a web storage area.
deleteAllKeys :: WebDriver wd => WebStorageType -> wd () Source
Delete all keys within a given web storage area.
getKey :: WebDriver wd => WebStorageType -> Text -> wd Text Source
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.
setKey :: WebDriver wd => WebStorageType -> Text -> Text -> wd Text Source
Set a key in the given web storage area.
deleteKey :: WebDriver wd => WebStorageType -> Text -> wd () Source
Delete a key in the given web storage area.
HTML 5 Application Cache
Mobile device support
Screen orientation
data Orientation Source
A screen orientation
getOrientation :: WebDriver wd => wd Orientation Source
Get the current screen orientation for rotatable display devices.
setOrientation :: WebDriver wd => Orientation -> wd () Source
Set the current screen orientation for rotatable display devices.
Geo-location
getLocation :: WebDriver wd => wd (Int, Int, Int) Source
Get the current geographical location of the device.
setLocation :: WebDriver wd => (Int, Int, Int) -> wd () Source
Set the current geographical location of the device.
Touch gestures
touchClick :: WebDriver wd => Element -> wd () Source
Single tap on the touch screen at the given element's location.
touchDown :: WebDriver wd => (Int, Int) -> wd () Source
Emulates pressing a finger down on the screen at the given location.
touchUp :: WebDriver wd => (Int, Int) -> wd () Source
Emulates removing a finger from the screen at the given location.
touchMove :: WebDriver wd => (Int, Int) -> wd () Source
Emulates moving a finger on the screen to the given location.
touchScroll :: WebDriver wd => (Int, Int) -> wd () Source
Emulate finger-based touch scroll. Use this function if you don't care where the scroll begins
touchScrollFrom :: WebDriver wd => (Int, Int) -> Element -> wd () Source
Emulate finger-based touch scroll, starting from the given location relative to the given element.
touchDoubleClick :: WebDriver wd => Element -> wd () Source
Emulate a double click on a touch device.
touchLongClick :: WebDriver wd => Element -> wd () Source
Emulate a long click on a touch device.
touchFlick :: WebDriver wd => (Int, Int) -> wd () Source
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.
:: WebDriver wd | |
=> Int | flick velocity |
-> (Int, Int) | a location relative to the given element |
-> Element | the given element |
-> wd () |
Emulate a flick on the touch screen.
IME support
availableIMEEngines :: WebDriver wd => wd [Text] Source
activeIMEEngine :: WebDriver wd => wd Text Source
checkIMEActive :: WebDriver wd => wd Bool Source
activateIME :: WebDriver wd => Text -> wd () Source
deactivateIME :: WebDriver wd => wd () Source
Uploading files to remote server
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.
uploadFile :: WebDriver wd => FilePath -> wd () Source
Uploads a file from the local filesystem by its file path.
:: WebDriver wd | |
=> FilePath | File path to use with this bytestring. |
-> Integer | Modification time (in seconds since Unix epoch). |
-> ByteString | The file contents as a lazy ByteString |
-> wd () |
Uploads a raw bytestring with associated file info.
uploadZipEntry :: WebDriver wd => Entry -> wd () Source
Lowest level interface to the file uploading mechanism. This allows you to specify the exact details of the zip entry sent across network.
Server information and logs
serverStatus :: WebDriver wd => wd Value Source
Get information from the server as a JSON Object
. For more information
about this object see
http://code.google.com/p/selenium/wiki/JsonWireProtocol#/status
getLogs :: WebDriver wd => LogType -> wd [LogEntry] Source
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
getLogTypes :: WebDriver wd => wd [LogType] Source
Get a list of available log types.
A record that represents a single log entry.