Safe Haskell | None |
---|---|
Language | Haskell2010 |
Test.WebDriver.Commands
Description
This module exports all the actions that can be used to interact with a browser session.
Synopsis
- emptyTimeouts :: Timeouts
- getTimeouts :: (HasCallStack, WebDriver wd) => wd Timeouts
- serverStatus :: (HasCallStack, WebDriver wd) => wd Value
- setImplicitWait :: (HasCallStack, WebDriver wd) => Integer -> wd ()
- setPageLoadTimeout :: (HasCallStack, WebDriver wd) => Integer -> wd ()
- setScriptTimeout :: (HasCallStack, WebDriver wd) => Maybe Integer -> wd ()
- setTimeouts :: (HasCallStack, WebDriver wd) => Timeouts -> wd ()
- data Timeouts = Timeouts {}
- back :: (HasCallStack, WebDriver wd) => wd ()
- forward :: (HasCallStack, WebDriver wd) => wd ()
- getCurrentURL :: (HasCallStack, WebDriver wd) => wd String
- getTitle :: (HasCallStack, WebDriver wd) => wd Text
- openPage :: (HasCallStack, WebDriver wd) => String -> wd ()
- refresh :: (HasCallStack, WebDriver wd) => wd ()
- closeWindow :: (HasCallStack, WebDriver wd) => WindowHandle -> wd ()
- focusFrame :: (HasCallStack, WebDriver wd) => FrameSelector -> wd ()
- focusParentFrame :: (HasCallStack, WebDriver wd) => wd ()
- focusWindow :: (HasCallStack, WebDriver wd) => WindowHandle -> wd ()
- fullscreen :: (HasCallStack, WebDriver wd) => wd ()
- getCurrentWindow :: (HasCallStack, WebDriver wd) => wd WindowHandle
- getWindowRect :: (HasCallStack, WebDriver wd) => wd Rect
- maximize :: (HasCallStack, WebDriver wd) => wd ()
- minimize :: (HasCallStack, WebDriver wd) => wd ()
- setWindowRect :: (HasCallStack, WebDriver wd) => Rect -> wd ()
- windows :: (HasCallStack, WebDriver wd) => wd [WindowHandle]
- data FrameSelector
- data Rect = Rect {}
- newtype WindowHandle = WindowHandle Text
- activeElem :: (HasCallStack, WebDriver wd) => wd Element
- findElem :: (HasCallStack, WebDriver wd) => Selector -> wd Element
- findElemFrom :: (HasCallStack, WebDriver wd) => Element -> Selector -> wd Element
- findElems :: (HasCallStack, WebDriver wd) => Selector -> wd [Element]
- findElemsFrom :: (HasCallStack, WebDriver wd) => Element -> Selector -> wd [Element]
- data Selector
- newtype Element = Element Text
- attr :: (HasCallStack, WebDriver wd) => Element -> Text -> wd (Maybe Text)
- cssProp :: (HasCallStack, WebDriver wd) => Element -> Text -> wd (Maybe Text)
- elemRect :: (HasCallStack, WebDriver wd) => Element -> wd Rect
- getText :: (HasCallStack, WebDriver wd) => Element -> wd Text
- isEnabled :: (HasCallStack, WebDriver wd) => Element -> wd Bool
- isSelected :: (HasCallStack, WebDriver wd) => Element -> wd Bool
- prop :: (HasCallStack, WebDriver wd) => Element -> Text -> wd (Maybe Value)
- tagName :: (HasCallStack, WebDriver wd) => Element -> wd Text
- clearInput :: (HasCallStack, WebDriver wd) => Element -> wd ()
- click :: (HasCallStack, WebDriver wd) => Element -> wd ()
- sendKeys :: (HasCallStack, WebDriver wd) => Text -> Element -> wd ()
- asyncJS :: (HasCallStack, Foldable f, FromJSON a, WebDriver wd) => f JSArg -> Text -> wd (Maybe a)
- executeJS :: (HasCallStack, Foldable f, FromJSON a, WebDriver wd) => f JSArg -> Text -> wd a
- getSource :: (HasCallStack, WebDriver wd) => wd Text
- data JSArg = ToJSON a => JSArg a
- ignoreReturn :: WebDriver m => m Value -> m ()
- cookie :: (HasCallStack, WebDriver wd) => Text -> wd Cookie
- cookies :: (HasCallStack, WebDriver wd) => wd [Cookie]
- deleteCookie :: (HasCallStack, WebDriver wd) => Text -> wd ()
- deleteCookies :: (HasCallStack, WebDriver wd) => wd ()
- mkCookie :: Text -> Text -> Cookie
- setCookie :: (HasCallStack, WebDriver wd) => Cookie -> wd ()
- data Cookie = Cookie {}
- clickCenter :: (HasCallStack, WebDriver wd) => Element -> wd ()
- doubleClickCenter :: (HasCallStack, WebDriver wd) => Element -> wd ()
- moveTo :: (HasCallStack, WebDriver wd) => (Int, Int) -> wd ()
- moveToCenter :: (HasCallStack, WebDriver wd) => Element -> wd ()
- moveToFrom :: (HasCallStack, WebDriver wd) => (Int, Int) -> Element -> wd ()
- performActions :: (HasCallStack, WebDriver wd) => [ActionSource] -> wd ()
- releaseActions :: (HasCallStack, WebDriver wd) => wd ()
- data Action
- = ActionPause {
- pauseDuration :: Int
- | ActionPointer { }
- | ActionKey { }
- = ActionPause {
- data ActionSource
- data KeyAction
- data MouseButton
- data PointerAction
- = PointerMove {
- moveOrigin :: PointerOrigin
- moveX :: Int
- moveY :: Int
- moveDuration :: Int
- | PointerDown { }
- | PointerUp { }
- | PointerCancel
- = PointerMove {
- data PointerOrigin
- acceptAlert :: (HasCallStack, WebDriver wd) => wd ()
- dismissAlert :: (HasCallStack, WebDriver wd) => wd ()
- getAlertText :: (HasCallStack, WebDriver wd) => wd Text
- replyToAlert :: (HasCallStack, WebDriver wd) => Text -> wd ()
- saveScreenshot :: (HasCallStack, WebDriver wd) => FilePath -> wd ()
- screenshot :: (HasCallStack, WebDriver wd) => wd ByteString
- screenshotElement :: (HasCallStack, WebDriver wd) => Element -> wd ByteString
- getLogs :: (HasCallStack, WebDriver wd) => LogType -> wd [LogEntry]
- withRecordLogsViaBiDi :: (WebDriver m, MonadLogger m) => (LogEntry -> m ()) -> m a -> m a
- withRecordLogsViaBiDi' :: (MonadUnliftIO m, MonadLogger m) => URI -> (LogEntry -> m ()) -> m a -> m a
- data LogEntry = LogEntry {}
- data LogLevel
- type LogType = String
- getLocation :: (HasCallStack, WebDriver wd) => wd (Int, Int, Int)
- getOrientation :: (HasCallStack, WebDriver wd) => wd Orientation
- setLocation :: (HasCallStack, WebDriver wd) => (Int, Int, Int) -> wd ()
- setOrientation :: (HasCallStack, WebDriver wd) => Orientation -> wd ()
- touchClick :: (HasCallStack, WebDriver wd) => Element -> wd ()
- touchDoubleClick :: (HasCallStack, WebDriver wd) => Element -> wd ()
- touchDown :: (HasCallStack, WebDriver wd) => (Int, Int) -> wd ()
- touchFlick :: (HasCallStack, WebDriver wd) => (Int, Int) -> wd ()
- touchFlickFrom :: (HasCallStack, WebDriver wd) => Int -> (Int, Int) -> Element -> wd ()
- touchLongClick :: (HasCallStack, WebDriver wd) => Element -> wd ()
- touchMove :: (HasCallStack, WebDriver wd) => (Int, Int) -> wd ()
- touchScroll :: (HasCallStack, WebDriver wd) => (Int, Int) -> wd ()
- touchScrollFrom :: (HasCallStack, WebDriver wd) => (Int, Int) -> Element -> wd ()
- touchUp :: (HasCallStack, WebDriver wd) => (Int, Int) -> wd ()
- data Orientation
- seleniumUploadFile :: (HasCallStack, WebDriver wd) => FilePath -> wd Text
- seleniumUploadRawFile :: (HasCallStack, WebDriver wd) => FilePath -> Integer -> ByteString -> wd Text
- seleniumUploadZipEntry :: (HasCallStack, WebDriver wd) => Entry -> wd Text
- deleteAllKeys :: (HasCallStack, WebDriver wd) => WebStorageType -> wd ()
- deleteKey :: (HasCallStack, WebDriver wd) => WebStorageType -> Text -> wd ()
- getAllKeys :: (HasCallStack, WebDriver wd) => WebStorageType -> wd [Text]
- getApplicationCacheStatus :: (HasCallStack, WebDriver wd) => wd ApplicationCacheStatus
- getKey :: (HasCallStack, WebDriver wd) => WebStorageType -> Text -> wd Text
- setKey :: (HasCallStack, WebDriver wd) => WebStorageType -> Text -> Text -> wd Text
- storageSize :: (HasCallStack, WebDriver wd) => WebStorageType -> wd Integer
- data ApplicationCacheStatus
- data WebStorageType
- (</=>) :: (HasCallStack, WebDriver wd) => Element -> Element -> wd Bool
- (<==>) :: (HasCallStack, WebDriver wd) => Element -> Element -> wd Bool
- isDisplayed :: (HasCallStack, WebDriver wd) => Element -> wd Bool
- submit :: (HasCallStack, WebDriver wd) => Element -> wd ()
Sessions
A session is equivalent to a single instantiation of a particular user agent, including all its child browsers. WebDriver gives each session a unique session ID that can be used to differentiate one session from another, allowing multiple user agents to be controlled from a single HTTP server, and allowing sessions to be routed via a multiplexer (known as an intermediary node).
See https://www.w3.org/TR/webdriver1/#sessions.
getTimeouts :: (HasCallStack, WebDriver wd) => wd Timeouts Source #
Get all the Timeouts
simultaneously.
serverStatus :: (HasCallStack, WebDriver wd) => wd Value Source #
Get information from the server as a JSON Object
. For more information
about this object see
https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#status
setImplicitWait :: (HasCallStack, WebDriver wd) => Integer -> wd () Source #
Set the "implicit" value of the Timeouts
.
setPageLoadTimeout :: (HasCallStack, WebDriver wd) => Integer -> wd () Source #
Set the "pageLoad" value of the Timeouts
.
setScriptTimeout :: (HasCallStack, WebDriver wd) => Maybe Integer -> wd () Source #
Set the "script" value of the Timeouts
.
Selenium 3 and 4 accept null
for this value, which unsets it. The spec doesn't mention this.
setTimeouts :: (HasCallStack, WebDriver wd) => Timeouts -> wd () Source #
Set all the Timeouts
simultaneously.
Constructors
Timeouts | |
Fields
|
Navigation
The commands in this section allow navigation of the current top-level browsing context to new URLs and introspection of the document currently loaded in this browsing context.
See https://www.w3.org/TR/webdriver1/#navigation.
back :: (HasCallStack, WebDriver wd) => wd () Source #
Navigate backward in the browser history.
forward :: (HasCallStack, WebDriver wd) => wd () Source #
Navigate forward in the browser history.
getCurrentURL :: (HasCallStack, WebDriver wd) => wd String Source #
Gets the URL of the current page.
openPage :: (HasCallStack, WebDriver wd) => String -> wd () Source #
Opens a new page by the given URL.
refresh :: (HasCallStack, WebDriver wd) => wd () Source #
Refresh the current page
Command contexts
Many WebDriver commands happen in the context of either the current browsing context or current top-level browsing context. The current top-level browsing context is represented in the protocol by its associated window handle. When a top-level browsing context is selected using the Switch To Window command, a specific browsing context can be selected using the Switch to Frame command.
See https://www.w3.org/TR/webdriver1/#command-contexts.
closeWindow :: (HasCallStack, WebDriver wd) => WindowHandle -> wd () Source #
Closes the given window
focusFrame :: (HasCallStack, WebDriver wd) => FrameSelector -> wd () Source #
Switch focus to the frame specified by the FrameSelector.
focusParentFrame :: (HasCallStack, WebDriver wd) => wd () Source #
Switch focus to the frame specified by the FrameSelector.
focusWindow :: (HasCallStack, WebDriver wd) => WindowHandle -> wd () Source #
Switch to a given window
fullscreen :: (HasCallStack, WebDriver wd) => wd () Source #
Fullscreens the current window
getCurrentWindow :: (HasCallStack, WebDriver wd) => wd WindowHandle Source #
Returns a handle to the currently focused window
getWindowRect :: (HasCallStack, WebDriver wd) => wd Rect Source #
Get the dimensions of the current window.
maximize :: (HasCallStack, WebDriver wd) => wd () Source #
Maximizes the current window
minimize :: (HasCallStack, WebDriver wd) => wd () Source #
Minimizes the current window
setWindowRect :: (HasCallStack, WebDriver wd) => Rect -> wd () Source #
Set the dimensions of the current window.
windows :: (HasCallStack, WebDriver wd) => wd [WindowHandle] Source #
Returns a list of all windows available to the session
data FrameSelector Source #
Specifies the frame used by focusFrame
Constructors
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. |
Instances
ToJSON FrameSelector Source # | |
Defined in Test.WebDriver.Commands.CommandContexts Methods toJSON :: FrameSelector -> Value # toEncoding :: FrameSelector -> Encoding # toJSONList :: [FrameSelector] -> Value # toEncodingList :: [FrameSelector] -> Encoding # omitField :: FrameSelector -> Bool # | |
Read FrameSelector Source # | |
Defined in Test.WebDriver.Commands.CommandContexts Methods readsPrec :: Int -> ReadS FrameSelector # readList :: ReadS [FrameSelector] # | |
Show FrameSelector Source # | |
Defined in Test.WebDriver.Commands.CommandContexts Methods showsPrec :: Int -> FrameSelector -> ShowS # show :: FrameSelector -> String # showList :: [FrameSelector] -> ShowS # | |
Eq FrameSelector Source # | |
Defined in Test.WebDriver.Commands.CommandContexts Methods (==) :: FrameSelector -> FrameSelector -> Bool # (/=) :: FrameSelector -> FrameSelector -> Bool # |
newtype WindowHandle Source #
An opaque identifier for a browser window
Constructors
WindowHandle Text |
Instances
Element Retrieval
The Find Element, Find Elements, Find Element From Element, and Find Elements From Element commands allow lookup of individual elements and collections of elements. Element retrieval searches are performed using pre-order traversal of the document’s nodes that match the provided selector’s expression. Elements are serialized and returned as web elements.
See https://www.w3.org/TR/webdriver1/#element-retrieval.
activeElem :: (HasCallStack, WebDriver wd) => wd Element Source #
Return the element that currently has focus.
findElem :: (HasCallStack, WebDriver wd) => Selector -> wd Element Source #
Find an element on the page using the given element selector.
findElemFrom :: (HasCallStack, WebDriver wd) => Element -> Selector -> wd Element Source #
Search for an element using the given element as root.
findElems :: (HasCallStack, WebDriver wd) => Selector -> wd [Element] Source #
Find all elements on the page matching the given selector.
findElemsFrom :: (HasCallStack, WebDriver wd) => Element -> Selector -> wd [Element] Source #
Find all elements matching a selector, using the given element as root.
Specifies element(s) within a DOM tree using various selection methods.
Constructors
ByCSS Text | |
ByLinkText Text | |
ByPartialLinkText Text | |
ByTag Text | |
ByXPath Text |
An opaque identifier for a web page element
Element State
attr :: (HasCallStack, WebDriver wd) => Element -> Text -> wd (Maybe Text) Source #
Retrieve the value of an element's attribute
cssProp :: (HasCallStack, WebDriver wd) => Element -> Text -> wd (Maybe Text) Source #
Retrieve the value of an element's computed CSS property
elemRect :: (HasCallStack, WebDriver wd) => Element -> wd Rect Source #
Retrieve an element's current position.
getText :: (HasCallStack, WebDriver wd) => Element -> wd Text Source #
Get all visible text within this element.
isEnabled :: (HasCallStack, WebDriver wd) => Element -> wd Bool Source #
Determine if the element is enabled.
isSelected :: (HasCallStack, WebDriver wd) => Element -> wd Bool Source #
Determine if the element is selected.
prop :: (HasCallStack, WebDriver wd) => Element -> Text -> wd (Maybe Value) Source #
Retrieve the value of an element's property
tagName :: (HasCallStack, WebDriver wd) => Element -> wd Text Source #
Return the tag name of the given element.
Element Interaction
clearInput :: (HasCallStack, WebDriver wd) => Element -> wd () Source #
Clear a textarea or text input element's value.
sendKeys :: (HasCallStack, 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. Named constants for special modifier keys can be found in Test.WebDriver.Keys
Document handling
asyncJS :: (HasCallStack, Foldable f, FromJSON a, WebDriver wd) => f 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
)
executeJS :: (HasCallStack, Foldable f, FromJSON a, WebDriver wd) => f 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 a sequence of 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.
When using executeJS
, GHC might complain about an ambiguous type in
situations where the result of the executeJS call is ignored/discard.
Consider the following example:
jsExample = do e <- findElem (ByCSS "#foo") executeJS [] "someAction()" return e
Because the result of the executeJS
is discarded, GHC cannot resolve
which instance of the fromJSON
class to use when parsing the
Selenium server response. In such cases, we can use the ignoreReturn
helper function located in Test.WebDriver.JSON. ignoreReturn
has
no runtime effect; it simply helps the type system by expicitly providing
a fromJSON
instance to use.
import Test.WebDriver.JSON (ignoreReturn) jsExample = do e <- findElem (ByCSS "#foo") ignoreReturn $ executeJS [] "someAction()" return e
An existential wrapper for any ToJSON
instance. This allows us to pass
parameters of many different types to Javascript code.
ignoreReturn :: WebDriver m => m Value -> m () Source #
Convenience function to ignore result of a webdriver command.
Cookies
cookie :: (HasCallStack, WebDriver wd) => Text -> wd Cookie Source #
Retrieve a specific cookie by name.
deleteCookie :: (HasCallStack, WebDriver wd) => Text -> wd () Source #
Delete a cookie by name.
deleteCookies :: (HasCallStack, WebDriver wd) => wd () Source #
Delete all visible cookies on the current page.
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 :: (HasCallStack, 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.
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.
Constructors
Cookie | |
Fields
|
Instances
Actions
clickCenter :: (HasCallStack, WebDriver wd) => Element -> wd () Source #
Helper to click the center of an element.
doubleClickCenter :: (HasCallStack, WebDriver wd) => Element -> wd () Source #
Helper to double click the center of an element.
moveTo :: (HasCallStack, WebDriver wd) => (Int, Int) -> wd () Source #
Moves the mouse to the given position relative to the current pointer position.
moveToCenter :: (HasCallStack, WebDriver wd) => Element -> wd () Source #
Moves the mouse to the center of a given element.
moveToFrom :: (HasCallStack, WebDriver wd) => (Int, Int) -> Element -> wd () Source #
Moves the mouse to the given position relative to the given element.
performActions :: (HasCallStack, WebDriver wd) => [ActionSource] -> wd () Source #
Perform a sequence of actions from multiple input sources
releaseActions :: (HasCallStack, WebDriver wd) => wd () Source #
Release all currently pressed keys and buttons
Generic action that can be pause, pointer, or key
Constructors
ActionPause | |
Fields
| |
ActionPointer | |
Fields | |
ActionKey | |
data ActionSource Source #
Action source (input device)
Constructors
PointerSource | |
KeySource | |
Instances
Show ActionSource Source # | |
Defined in Test.WebDriver.Commands.Actions Methods showsPrec :: Int -> ActionSource -> ShowS # show :: ActionSource -> String # showList :: [ActionSource] -> ShowS # | |
Eq ActionSource Source # | |
Defined in Test.WebDriver.Commands.Actions |
data MouseButton Source #
A mouse button
Constructors
LeftButton | |
MiddleButton | |
RightButton |
Instances
FromJSON MouseButton Source # | |
Defined in Test.WebDriver.Commands.Actions | |
ToJSON MouseButton Source # | |
Defined in Test.WebDriver.Commands.Actions Methods toJSON :: MouseButton -> Value # toEncoding :: MouseButton -> Encoding # toJSONList :: [MouseButton] -> Value # toEncodingList :: [MouseButton] -> Encoding # omitField :: MouseButton -> Bool # | |
Bounded MouseButton Source # | |
Defined in Test.WebDriver.Commands.Actions | |
Enum MouseButton Source # | |
Defined in Test.WebDriver.Commands.Actions Methods succ :: MouseButton -> MouseButton # pred :: MouseButton -> MouseButton # toEnum :: Int -> MouseButton # fromEnum :: MouseButton -> Int # enumFrom :: MouseButton -> [MouseButton] # enumFromThen :: MouseButton -> MouseButton -> [MouseButton] # enumFromTo :: MouseButton -> MouseButton -> [MouseButton] # enumFromThenTo :: MouseButton -> MouseButton -> MouseButton -> [MouseButton] # | |
Show MouseButton Source # | |
Defined in Test.WebDriver.Commands.Actions Methods showsPrec :: Int -> MouseButton -> ShowS # show :: MouseButton -> String # showList :: [MouseButton] -> ShowS # | |
Eq MouseButton Source # | |
Defined in Test.WebDriver.Commands.Actions | |
Ord MouseButton Source # | |
Defined in Test.WebDriver.Commands.Actions Methods compare :: MouseButton -> MouseButton -> Ordering # (<) :: MouseButton -> MouseButton -> Bool # (<=) :: MouseButton -> MouseButton -> Bool # (>) :: MouseButton -> MouseButton -> Bool # (>=) :: MouseButton -> MouseButton -> Bool # max :: MouseButton -> MouseButton -> MouseButton # min :: MouseButton -> MouseButton -> MouseButton # |
data PointerAction Source #
Individual pointer actions
Constructors
PointerMove | |
Fields
| |
PointerDown | |
Fields | |
PointerUp | |
Fields | |
PointerCancel |
Instances
Show PointerAction Source # | |
Defined in Test.WebDriver.Commands.Actions Methods showsPrec :: Int -> PointerAction -> ShowS # show :: PointerAction -> String # showList :: [PointerAction] -> ShowS # | |
Eq PointerAction Source # | |
Defined in Test.WebDriver.Commands.Actions Methods (==) :: PointerAction -> PointerAction -> Bool # (/=) :: PointerAction -> PointerAction -> Bool # |
data PointerOrigin Source #
Origin for pointer actions
Constructors
PointerViewport | |
PointerCurrent | |
PointerElement Element |
Instances
Show PointerOrigin Source # | |
Defined in Test.WebDriver.Commands.Actions Methods showsPrec :: Int -> PointerOrigin -> ShowS # show :: PointerOrigin -> String # showList :: [PointerOrigin] -> ShowS # | |
Eq PointerOrigin Source # | |
Defined in Test.WebDriver.Commands.Actions Methods (==) :: PointerOrigin -> PointerOrigin -> Bool # (/=) :: PointerOrigin -> PointerOrigin -> Bool # |
User Prompts
acceptAlert :: (HasCallStack, WebDriver wd) => wd () Source #
Accepts the currently displayed alert dialog.
dismissAlert :: (HasCallStack, WebDriver wd) => wd () Source #
Dismisses the currently displayed alert dialog.
getAlertText :: (HasCallStack, WebDriver wd) => wd Text Source #
Get the text of an alert dialog.
replyToAlert :: (HasCallStack, WebDriver wd) => Text -> wd () Source #
Sends keystrokes to Javascript prompt() dialog.
Screen capture
saveScreenshot :: (HasCallStack, WebDriver wd) => FilePath -> wd () Source #
Save a screenshot to a particular location.
screenshot :: (HasCallStack, WebDriver wd) => wd ByteString Source #
Grab a screenshot of the current page as a PNG image.
screenshotElement :: (HasCallStack, WebDriver wd) => Element -> wd ByteString Source #
Grab a screenshot of the current page as a PNG image.
Browser logs
Retrieve browser console logs and other log types.
getLogs :: (HasCallStack, WebDriver wd) => LogType -> wd [LogEntry] Source #
Retrieve logs of a specific type from the browser. The W3C spec doesn't define how to do this natively, so we automatically detect the browser and try to use an appropriate method:
- Chrome/Chromium: Chrome DevTools Protocol (CDP)
- Firefox: legacy log endpoint (/log)
- Selenium: legacy log endpoint (/log)
- Other browsers: returns empty list
Common log types: browser
, driver
, performance
, server
.
However, the modern way to do this is via withRecordLogsViaBiDi
.
withRecordLogsViaBiDi :: (WebDriver m, MonadLogger m) => (LogEntry -> m ()) -> m a -> m a Source #
Wrapper around withRecordLogsViaBiDi'
which uses the WebSocket URL from
the current Session
. You must make sure to pass _capabilitiesWebSocketUrl
= Just True
to enable this. This will not work with Selenium 3.
withRecordLogsViaBiDi' :: (MonadUnliftIO m, MonadLogger m) => URI -> (LogEntry -> m ()) -> m a -> m a Source #
Connect to WebSocket URL and subscribe to log events using the W3C BiDi protocol; see https://w3c.github.io/webdriver-bidi/.
A record that represents a single log entry.
Constructors
LogEntry | |
Indicates a log verbosity level.
Constructors
LogOff | |
LogSevere | |
LogWarning | |
LogInfo | |
LogConfig | |
LogFine | |
LogFiner | |
LogFinest | |
LogDebug | |
LogAll |
Instances
FromJSON LogLevel Source # | |
Defined in Test.WebDriver.Commands.Logs.Common | |
ToJSON LogLevel Source # | |
Bounded LogLevel Source # | |
Enum LogLevel Source # | |
Defined in Test.WebDriver.Commands.Logs.Common | |
Read LogLevel Source # | |
Show LogLevel Source # | |
Eq LogLevel Source # | |
Ord LogLevel Source # | |
Defined in Test.WebDriver.Commands.Logs.Common |
Selenium-specific
Mobile device support
getLocation :: (HasCallStack, WebDriver wd) => wd (Int, Int, Int) Source #
Get the current geographical location of the device.
getOrientation :: (HasCallStack, WebDriver wd) => wd Orientation Source #
Get the current screen orientation for rotatable display devices.
setLocation :: (HasCallStack, WebDriver wd) => (Int, Int, Int) -> wd () Source #
Set the current geographical location of the device.
setOrientation :: (HasCallStack, WebDriver wd) => Orientation -> wd () Source #
Set the current screen orientation for rotatable display devices.
touchClick :: (HasCallStack, WebDriver wd) => Element -> wd () Source #
Single tap on the touch screen at the given element's location.
touchDoubleClick :: (HasCallStack, WebDriver wd) => Element -> wd () Source #
Emulate a double click on a touch device.
touchDown :: (HasCallStack, WebDriver wd) => (Int, Int) -> wd () Source #
Emulates pressing a finger down on the screen at the given location.
touchFlick :: (HasCallStack, 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.
Arguments
:: (HasCallStack, 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.
touchLongClick :: (HasCallStack, WebDriver wd) => Element -> wd () Source #
Emulate a long click on a touch device.
touchMove :: (HasCallStack, WebDriver wd) => (Int, Int) -> wd () Source #
Emulates moving a finger on the screen to the given location.
touchScroll :: (HasCallStack, WebDriver wd) => (Int, Int) -> wd () Source #
Emulate finger-based touch scroll. Use this function if you don't care where the scroll begins
touchScrollFrom :: (HasCallStack, WebDriver wd) => (Int, Int) -> Element -> wd () Source #
Emulate finger-based touch scroll, starting from the given location relative to the given element.
touchUp :: (HasCallStack, WebDriver wd) => (Int, Int) -> wd () Source #
Emulates removing a finger from the screen at the given location.
data Orientation Source #
A screen orientation
Instances
FromJSON Orientation Source # | |
ToJSON Orientation Source # | |
Defined in Test.WebDriver.Commands.SeleniumSpecific.Mobile Methods toJSON :: Orientation -> Value # toEncoding :: Orientation -> Encoding # toJSONList :: [Orientation] -> Value # toEncodingList :: [Orientation] -> Encoding # omitField :: Orientation -> Bool # | |
Bounded Orientation Source # | |
Enum Orientation Source # | |
Defined in Test.WebDriver.Commands.SeleniumSpecific.Mobile Methods succ :: Orientation -> Orientation # pred :: Orientation -> Orientation # toEnum :: Int -> Orientation # fromEnum :: Orientation -> Int # enumFrom :: Orientation -> [Orientation] # enumFromThen :: Orientation -> Orientation -> [Orientation] # enumFromTo :: Orientation -> Orientation -> [Orientation] # enumFromThenTo :: Orientation -> Orientation -> Orientation -> [Orientation] # | |
Show Orientation Source # | |
Defined in Test.WebDriver.Commands.SeleniumSpecific.Mobile Methods showsPrec :: Int -> Orientation -> ShowS # show :: Orientation -> String # showList :: [Orientation] -> ShowS # | |
Eq Orientation Source # | |
Ord Orientation Source # | |
Defined in Test.WebDriver.Commands.SeleniumSpecific.Mobile Methods compare :: Orientation -> Orientation -> Ordering # (<) :: Orientation -> Orientation -> Bool # (<=) :: Orientation -> Orientation -> Bool # (>) :: Orientation -> Orientation -> Bool # (>=) :: Orientation -> Orientation -> Bool # max :: Orientation -> Orientation -> Orientation # min :: Orientation -> Orientation -> Orientation # |
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.
seleniumUploadFile :: (HasCallStack, WebDriver wd) => FilePath -> wd Text Source #
Uploads a file from the local filesystem by its file path. Returns the remote filepath of the file.
seleniumUploadRawFile Source #
Arguments
:: (HasCallStack, 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 Text |
Uploads a raw ByteString
with associated file info. Returns the
remote filepath of the file.
seleniumUploadZipEntry :: (HasCallStack, WebDriver wd) => Entry -> wd Text Source #
Lowest level interface to the file uploading mechanism. This allows you to specify the exact details of the zip entry sent across network. Returns the remote filepath of the extracted file
HTML5
deleteAllKeys :: (HasCallStack, WebDriver wd) => WebStorageType -> wd () Source #
Delete all keys within a given web storage area.
deleteKey :: (HasCallStack, WebDriver wd) => WebStorageType -> Text -> wd () Source #
Delete a key in the given web storage area.
getAllKeys :: (HasCallStack, WebDriver wd) => WebStorageType -> wd [Text] Source #
Get a list of all keys from a web storage area.
getApplicationCacheStatus :: (HasCallStack, WebDriver wd) => wd ApplicationCacheStatus Source #
getKey :: (HasCallStack, 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 :: (HasCallStack, WebDriver wd) => WebStorageType -> Text -> Text -> wd Text Source #
Set a key in the given web storage area.
storageSize :: (HasCallStack, WebDriver wd) => WebStorageType -> wd Integer Source #
Get the current number of keys in a web storage area.
data ApplicationCacheStatus Source #
Constructors
Uncached | |
Idle | |
Checking | |
Downloading | |
UpdateReady | |
Obsolete |
Instances
FromJSON ApplicationCacheStatus Source # | |
Defined in Test.WebDriver.Commands.SeleniumSpecific.HTML5 Methods parseJSON :: Value -> Parser ApplicationCacheStatus # parseJSONList :: Value -> Parser [ApplicationCacheStatus] # | |
ToJSON ApplicationCacheStatus Source # | |
Defined in Test.WebDriver.Commands.SeleniumSpecific.HTML5 Methods toJSON :: ApplicationCacheStatus -> Value # toEncoding :: ApplicationCacheStatus -> Encoding # toJSONList :: [ApplicationCacheStatus] -> Value # toEncodingList :: [ApplicationCacheStatus] -> Encoding # omitField :: ApplicationCacheStatus -> Bool # | |
Bounded ApplicationCacheStatus Source # | |
Enum ApplicationCacheStatus Source # | |
Defined in Test.WebDriver.Commands.SeleniumSpecific.HTML5 Methods succ :: ApplicationCacheStatus -> ApplicationCacheStatus # pred :: ApplicationCacheStatus -> ApplicationCacheStatus # toEnum :: Int -> ApplicationCacheStatus # fromEnum :: ApplicationCacheStatus -> Int # enumFrom :: ApplicationCacheStatus -> [ApplicationCacheStatus] # enumFromThen :: ApplicationCacheStatus -> ApplicationCacheStatus -> [ApplicationCacheStatus] # enumFromTo :: ApplicationCacheStatus -> ApplicationCacheStatus -> [ApplicationCacheStatus] # enumFromThenTo :: ApplicationCacheStatus -> ApplicationCacheStatus -> ApplicationCacheStatus -> [ApplicationCacheStatus] # | |
Read ApplicationCacheStatus Source # | |
Show ApplicationCacheStatus Source # | |
Defined in Test.WebDriver.Commands.SeleniumSpecific.HTML5 Methods showsPrec :: Int -> ApplicationCacheStatus -> ShowS # show :: ApplicationCacheStatus -> String # showList :: [ApplicationCacheStatus] -> ShowS # | |
Eq ApplicationCacheStatus Source # | |
Defined in Test.WebDriver.Commands.SeleniumSpecific.HTML5 Methods (==) :: ApplicationCacheStatus -> ApplicationCacheStatus -> Bool # (/=) :: ApplicationCacheStatus -> ApplicationCacheStatus -> Bool # | |
Ord ApplicationCacheStatus Source # | |
Defined in Test.WebDriver.Commands.SeleniumSpecific.HTML5 Methods compare :: ApplicationCacheStatus -> ApplicationCacheStatus -> Ordering # (<) :: ApplicationCacheStatus -> ApplicationCacheStatus -> Bool # (<=) :: ApplicationCacheStatus -> ApplicationCacheStatus -> Bool # (>) :: ApplicationCacheStatus -> ApplicationCacheStatus -> Bool # (>=) :: ApplicationCacheStatus -> ApplicationCacheStatus -> Bool # max :: ApplicationCacheStatus -> ApplicationCacheStatus -> ApplicationCacheStatus # min :: ApplicationCacheStatus -> ApplicationCacheStatus -> ApplicationCacheStatus # |
data WebStorageType Source #
An HTML 5 storage type
Constructors
LocalStorage | |
SessionStorage |
Instances
Bounded WebStorageType Source # | |
Enum WebStorageType Source # | |
Defined in Test.WebDriver.Commands.SeleniumSpecific.HTML5 Methods succ :: WebStorageType -> WebStorageType # pred :: WebStorageType -> WebStorageType # toEnum :: Int -> WebStorageType # fromEnum :: WebStorageType -> Int # enumFrom :: WebStorageType -> [WebStorageType] # enumFromThen :: WebStorageType -> WebStorageType -> [WebStorageType] # enumFromTo :: WebStorageType -> WebStorageType -> [WebStorageType] # enumFromThenTo :: WebStorageType -> WebStorageType -> WebStorageType -> [WebStorageType] # | |
Show WebStorageType Source # | |
Defined in Test.WebDriver.Commands.SeleniumSpecific.HTML5 Methods showsPrec :: Int -> WebStorageType -> ShowS # show :: WebStorageType -> String # showList :: [WebStorageType] -> ShowS # | |
Eq WebStorageType Source # | |
Defined in Test.WebDriver.Commands.SeleniumSpecific.HTML5 Methods (==) :: WebStorageType -> WebStorageType -> Bool # (/=) :: WebStorageType -> WebStorageType -> Bool # | |
Ord WebStorageType Source # | |
Defined in Test.WebDriver.Commands.SeleniumSpecific.HTML5 Methods compare :: WebStorageType -> WebStorageType -> Ordering # (<) :: WebStorageType -> WebStorageType -> Bool # (<=) :: WebStorageType -> WebStorageType -> Bool # (>) :: WebStorageType -> WebStorageType -> Bool # (>=) :: WebStorageType -> WebStorageType -> Bool # max :: WebStorageType -> WebStorageType -> WebStorageType # min :: WebStorageType -> WebStorageType -> WebStorageType # |
Misc
(</=>) :: (HasCallStack, WebDriver wd) => Element -> Element -> wd Bool infix 4 Source #
Determines if two element identifiers refer to different elements.
(<==>) :: (HasCallStack, WebDriver wd) => Element -> Element -> wd Bool infix 4 Source #
Determines if two element identifiers refer to the same element.
isDisplayed :: (HasCallStack, WebDriver wd) => Element -> wd Bool Source #
Determine if the element is displayed. This function isn't guaranteed to be implemented by the WebDriver spec, but it is found in Selenium. See https://www.w3.org/TR/webdriver1/#element-displayedness.