Safe Haskell | Safe-Infered |
---|
This module exports basic WD actions that can be used to interact with a browser session.
- createSession :: Capabilities -> WD WDSession
- closeSession :: WD ()
- sessions :: WD [(SessionId, Capabilities)]
- getCaps :: WD Capabilities
- openPage :: String -> WD ()
- forward :: WD ()
- back :: WD ()
- refresh :: WD ()
- getCurrentURL :: WD String
- getSource :: WD Text
- getTitle :: WD Text
- screenshot :: WD ByteString
- setImplicitWait :: Integer -> WD ()
- setScriptTimeout :: Integer -> WD ()
- newtype Element = Element Text
- data Selector
- findElem :: Selector -> WD Element
- findElems :: Selector -> WD [Element]
- findElemFrom :: Element -> Selector -> WD Element
- findElemsFrom :: Element -> Selector -> WD [Element]
- click :: Element -> WD ()
- submit :: Element -> WD ()
- getText :: Element -> WD Text
- sendKeys :: Text -> Element -> WD ()
- sendRawKeys :: Text -> Element -> WD ()
- clearInput :: Element -> WD ()
- attr :: Element -> Text -> WD (Maybe Text)
- cssProp :: Element -> Text -> WD (Maybe Text)
- elemPos :: Element -> WD (Int, Int)
- elemSize :: Element -> WD (Word, Word)
- isSelected :: Element -> WD Bool
- isEnabled :: Element -> WD Bool
- isDisplayed :: Element -> WD Bool
- tagName :: Element -> WD Text
- activeElem :: WD Element
- elemInfo :: Element -> WD Value
- (<==>) :: Element -> Element -> WD Bool
- (</=>) :: Element -> Element -> WD Bool
- executeJS :: FromJSON a => [JSArg] -> Text -> WD a
- asyncJS :: FromJSON a => [JSArg] -> Text -> WD (Maybe a)
- data JSArg = forall a . ToJSON a => JSArg a
- newtype WindowHandle = WindowHandle Text
- currentWindow :: WindowHandle
- getCurrentWindow :: WD WindowHandle
- focusWindow :: WindowHandle -> WD ()
- closeWindow :: WindowHandle -> WD ()
- windows :: WD [WindowHandle]
- getWindowSize :: WindowHandle -> WD (Word, Word)
- setWindowSize :: WindowHandle -> (Word, Word) -> WD ()
- getWindowPos :: WindowHandle -> WD (Int, Int)
- setWindowPos :: WindowHandle -> (Int, Int) -> WD ()
- data Cookie = Cookie {}
- cookies :: WD [Cookie]
- setCookie :: Cookie -> WD ()
- deleteCookie :: Cookie -> WD ()
- deleteVisibleCookies :: WD ()
- getAlertText :: WD Text
- replyToAlert :: Text -> WD ()
- acceptAlert :: WD ()
- dismissAlert :: WD ()
- moveTo :: (Int, Int) -> WD ()
- moveToCenter :: Element -> WD ()
- moveToFrom :: (Int, Int) -> Element -> WD ()
- clickWith :: MouseButton -> WD ()
- data MouseButton
- mouseDown :: WD ()
- mouseUp :: WD ()
- withMouseDown :: WD a -> WD a
- doubleClick :: WD ()
- touchClick :: Element -> WD ()
- touchDown :: (Int, Int) -> WD ()
- touchUp :: (Int, Int) -> WD ()
- touchMove :: (Int, Int) -> WD ()
- touchScroll :: (Int, Int) -> WD ()
- touchScrollFrom :: (Int, Int) -> Element -> WD ()
- touchDoubleClick :: Element -> WD ()
- touchLongClick :: Element -> WD ()
- touchFlick :: (Int, Int) -> WD ()
- touchFlickFrom :: Int -> (Int, Int) -> Element -> WD ()
- data Orientation
- getOrientation :: WD Orientation
- setOrientation :: Orientation -> WD ()
- getLocation :: WD (Int, Int, Int)
- setLocation :: (Int, Int, Int) -> WD ()
- availableIMEEngines :: WD [Text]
- activeIMEEngine :: WD Text
- checkIMEActive :: WD Bool
- activateIME :: Text -> WD ()
- deactivateIME :: WD ()
- serverStatus :: WD Value
Sessions
createSession :: Capabilities -> WD WDSessionSource
Create a new session with the given Capabilities
. This command
resets the current session ID to that of the new session.
Close the current session and the browser associated with it.
sessions :: WD [(SessionId, Capabilities)]Source
Retrieve a list of active sessions and their Capabilities
.
getCaps :: WD CapabilitiesSource
Get the actual Capabilities
of the current session.
Browser interaction
Web navigation
Page info
getCurrentURL :: WD StringSource
Gets the URL of the current page.
screenshot :: WD ByteStringSource
Grab a screenshot of the current page as a PNG image
Timeouts
setImplicitWait :: Integer -> WD ()Source
Sets the amount of time we implicitly wait when searching for Elements
.
setScriptTimeout :: Integer -> WD ()Source
Sets the amount of time we wait for an asynchronous script to return a result
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 :: Selector -> WD ElementSource
Find an element on the page using the given element selector.
findElems :: Selector -> WD [Element]Source
Find all elements on the page matching the given selector.
findElemFrom :: Element -> Selector -> WD ElementSource
Search for an element using the given element as root.
findElemsFrom :: Element -> Selector -> WD [Element]Source
Find all elements matching a selector, using the given element as root.
Interacting with elements
submit :: Element -> WD ()Source
Submit a form element. This may be applied to descendents of a form element as well.
sendKeys :: 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 :: 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 :: Element -> WD ()Source
Clear a textarea or text input element's value.
Element information
cssProp :: Element -> Text -> WD (Maybe Text)Source
Retrieve the value of an element's computed CSS property
isSelected :: Element -> WD BoolSource
Determine if the element is selected.
isDisplayed :: Element -> WD BoolSource
Determine if the element is displayed.
activeElem :: WD ElementSource
Return the element that currently has focus.
elemInfo :: Element -> WD ValueSource
Describe the element. Returns a JSON object whose meaning is currently undefined by the WebDriver protocol.
Element equality
(<==>) :: Element -> Element -> WD BoolSource
Determines if two element identifiers refer to the same element.
(</=>) :: Element -> Element -> WD BoolSource
Determines if two element identifiers refer to different elements.
Javascript
executeJS :: FromJSON a => [JSArg] -> Text -> WD aSource
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 :: 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 :: WindowHandleSource
A special WindowHandle
that always refers to the currently focused window.
getCurrentWindow :: WD WindowHandleSource
Returns a handle to the currently focused window
focusWindow :: WindowHandle -> WD ()Source
Switches focus to a given window.
closeWindow :: WindowHandle -> WD ()Source
Closes the given window
windows :: WD [WindowHandle]Source
Returns a list of all windows available to the session
getWindowSize :: WindowHandle -> WD (Word, Word)Source
Get the dimensions of the given window.
setWindowSize :: WindowHandle -> (Word, Word) -> WD ()Source
Set the dimensions of the given window.
getWindowPos :: WindowHandle -> WD (Int, Int)Source
Get the coordinates of the given window.
setWindowPos :: WindowHandle -> (Int, Int) -> WD ()Source
Set the coordinates of the given window.
Cookies
Cookies are delicious delicacies.
setCookie :: 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 :: Cookie -> WD ()Source
Delete a cookie. This will do nothing is the cookie isn't visible to the current page.
deleteVisibleCookies :: WD ()Source
Delete all visible cookies on the current page.
Alerts
Get the text of an alert dialog.
replyToAlert :: Text -> WD ()Source
Sends keystrokes to Javascript prompt() dialog.
Accepts the currently displayed alert dialog.
Dismisses the currently displayed alert dialog.
Mouse gestures
moveTo :: (Int, Int) -> WD ()Source
Moves the mouse to the given position relative to the active element.
moveToCenter :: Element -> WD ()Source
Moves the mouse to the center of a given element.
moveToFrom :: (Int, Int) -> Element -> WD ()Source
Moves the mouse to the given position relative to the given element.
clickWith :: MouseButton -> WD ()Source
Click at the current mouse position with the given mouse button.
data MouseButton Source
A mouse button
Press and hold the left mouse button down. Note that undefined behavior occurs if the next mouse command is not mouseUp.
withMouseDown :: WD a -> WD aSource
Perform the given action with the left mouse button held down. The mouse is automatically released afterwards.
Double click at the current mouse location.
Touch gestures
touchClick :: Element -> WD ()Source
Single tap on the touch screen at the given element's location.
touchDown :: (Int, Int) -> WD ()Source
Emulates pressing a finger down on the screen at the given location.
touchUp :: (Int, Int) -> WD ()Source
Emulates removing a finger from the screen at the given location.
touchScroll :: (Int, Int) -> WD ()Source
Emulate finger-based touch scroll. Use this function if you don't care where the scroll begins
touchScrollFrom :: (Int, Int) -> Element -> WD ()Source
Emulate finger-based touch scroll, starting from the given location relative to the given element.
touchDoubleClick :: Element -> WD ()Source
Emulate a double click on a touch device.
touchLongClick :: Element -> WD ()Source
Emulate a long click on a touch device.
touchFlick :: (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.
:: Int | flick velocity |
-> (Int, Int) | a location relative to the given element |
-> Element | the given element |
-> WD () |
Emulate a flick on the touch screen.
Screen orientation
data Orientation Source
A screen orientation
getOrientation :: WD OrientationSource
Get the current screen orientation for rotatable display devices.
setOrientation :: Orientation -> WD ()Source
Set the current screen orientation for rotatable display devices.
Geo-location
IME support
activateIME :: Text -> WD ()Source
Server information
serverStatus :: WD ValueSource
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