| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Test.Sandwich.WebDriver
Description
Introduce WebDriver servers and sessions.
Synopsis
- introduceWebDriver :: forall context m. (BaseMonad m context, HasSomeCommandLineOptions context) => WebDriverDependencies -> WdOptions -> SpecFree (ContextWithWebdriverDeps context) m () -> SpecFree context m ()
- introduceWebDriverViaNix :: forall m context. (BaseMonad m context, HasSomeCommandLineOptions context, HasNixContext context) => WdOptions -> SpecFree (ContextWithWebdriverDeps context) m () -> SpecFree context m ()
- introduceWebDriverViaNix' :: forall m context. (BaseMonad m context, HasSomeCommandLineOptions context, HasNixContext context) => NodeOptions -> WdOptions -> SpecFree (ContextWithWebdriverDeps context) m () -> SpecFree context m ()
- defaultWebDriverDependencies :: WebDriverDependencies
- data WebDriverDependencies = WebDriverDependencies {}
- withSession :: forall m context a. (MonadMask m, MonadBaseControl IO m, HasBaseContext context, HasSomeCommandLineOptions context, WebDriverMonad m context) => Session -> ExampleT (LabelValue "webdriverSession" WebDriverSession :> context) m a -> ExampleT context m a
- withSession1 :: (MonadMask m, MonadBaseControl IO m, HasBaseContext context, HasSomeCommandLineOptions context, WebDriverMonad m context) => ExampleT (LabelValue "webdriverSession" WebDriverSession :> context) m a -> ExampleT context m a
- withSession2 :: (MonadMask m, MonadBaseControl IO m, HasBaseContext context, HasSomeCommandLineOptions context, WebDriverMonad m context) => ExampleT (LabelValue "webdriverSession" WebDriverSession :> context) m a -> ExampleT context m a
- getSessions :: (MonadReader context m, WebDriverMonad m context) => m [Session]
- closeCurrentSession :: (MonadLogger m, WebDriverSessionMonad m context) => m ()
- closeSession :: (HasCallStack, MonadLogger m, MonadUnliftIO m) => Session -> WebDriver -> m ()
- closeAllSessions :: (HasCallStack, MonadLogger m, MonadUnliftIO m) => WebDriver -> m ()
- closeAllSessionsExcept :: (HasCallStack, MonadLogger m, MonadUnliftIO m) => [Session] -> WebDriver -> m ()
- type Session = String
- allocateWebDriver :: (BaseMonad m context, HasFile context "java", HasFile context "selenium.jar", HasBrowserDependencies context) => WdOptions -> OnDemandOptions -> ExampleT context m WebDriver
- cleanupWebDriver :: BaseMonad m context => WebDriver -> ExampleT context m ()
- introduceBrowserDependenciesViaNix :: forall m context. (MonadUnliftIO m, HasBaseContext context, HasNixContext context, HasSomeCommandLineOptions context) => SpecFree (LabelValue "browserDependencies" BrowserDependencies :> context) m () -> SpecFree context m ()
- introduceBrowserDependenciesViaNix' :: forall m context. (MonadUnliftIO m, HasBaseContext context, HasNixContext context, HasSomeCommandLineOptions context) => NodeOptions -> SpecFree (LabelValue "browserDependencies" BrowserDependencies :> context) m () -> SpecFree context m ()
- introduceWebDriver' :: forall m context. BaseMonad m context => WebDriverDependencies -> (WdOptions -> ExampleT (ContextWithBaseDeps context) m WebDriver) -> WdOptions -> SpecFree (ContextWithWebdriverDeps context) m () -> SpecFree context m ()
- addCommandLineOptionsToWdOptions :: SomeCommandLineOptions -> WdOptions -> WdOptions
- webdriver :: Label "webdriver" WebDriver
- data WebDriver
- type HasWebDriverContext context = HasLabel context "webdriver" WebDriver
- webdriverSession :: Label "webdriverSession" WebDriverSession
- type WebDriverSession = (Session, IORef WDSession)
- type HasWebDriverSessionContext context = HasLabel context "webdriverSession" WebDriverSession
- type BaseMonad m context = (HasCallStack, MonadUnliftIO m, MonadMask m, HasBaseContext context)
- type ContextWithBaseDeps context = LabelValue "browserDependencies" BrowserDependencies :> (FileValue "java" :> (FileValue "selenium.jar" :> context))
- type ContextWithWebdriverDeps context = LabelValue "webdriver" WebDriver :> ContextWithBaseDeps context
- type WebDriverMonad m context = (HasCallStack, MonadUnliftIO m, HasWebDriverContext context)
- type WebDriverSessionMonad m context = (WebDriverMonad m context, MonadReader context m, HasWebDriverSessionContext context)
- data OnDemandOptions
- defaultOnDemandOptions :: OnDemandOptions
- module Test.Sandwich.WebDriver.Config
Introducing a WebDriver server
Arguments
| :: forall context m. (BaseMonad m context, HasSomeCommandLineOptions context) | |
| => WebDriverDependencies | How to obtain dependencies |
| -> WdOptions | |
| -> SpecFree (ContextWithWebdriverDeps context) m () | |
| -> SpecFree context m () |
Introduce a WebDriver, using the given WebDriverDependencies.
A good default is defaultWebDriverDependencies.
introduceWebDriverViaNix Source #
Arguments
| :: forall m context. (BaseMonad m context, HasSomeCommandLineOptions context, HasNixContext context) | |
| => WdOptions | Options |
| -> SpecFree (ContextWithWebdriverDeps context) m () | |
| -> SpecFree context m () |
Introduce a WebDriver using the current NixContext.
This will pull everything required from the configured Nixpkgs snapshot.
introduceWebDriverViaNix' Source #
Arguments
| :: forall m context. (BaseMonad m context, HasSomeCommandLineOptions context, HasNixContext context) | |
| => NodeOptions | |
| -> WdOptions | Options |
| -> SpecFree (ContextWithWebdriverDeps context) m () | |
| -> SpecFree context m () |
Same as introduceWebDriverViaNix, but allows passing custom NodeOptions.
Non-Nix dependency fetching
When you aren't using Nix, these types specify how to obtain the necessary dependencies.
defaultWebDriverDependencies :: WebDriverDependencies Source #
This configuration will
- Use
javafrom the PATH, failing if it isn't found. - Download Selenium to
/tmp/tools, reusing the one there if found. - Use
firefoxfrom the PATH as the browser. - Download a compatible
geckodriverto/tmp/tools, reusing the one there if found. - If applicable, it will also get
Xvfb,fluxbox, and/orffmpegfrom the PATH.
But, it's easy to customize this behavior. You can define your own WebDriverDependencies and customize
how each of these dependencies are found.
data WebDriverDependencies Source #
This type describes how we should obtain all the dependencies needed to launch a WebDriver session. You can configure them individually.
Constructors
| WebDriverDependencies | |
Fields
| |
Running an example in a given session
Once you have a WebDriver in context, you can run one or more sessions.
Each session will open an independent browser instance.
Arguments
| :: forall m context a. (MonadMask m, MonadBaseControl IO m, HasBaseContext context, HasSomeCommandLineOptions context, WebDriverMonad m context) | |
| => Session | Session to run |
| -> ExampleT (LabelValue "webdriverSession" WebDriverSession :> context) m a | |
| -> ExampleT context m a |
Run a given example using a given Selenium session.
Arguments
| :: (MonadMask m, MonadBaseControl IO m, HasBaseContext context, HasSomeCommandLineOptions context, WebDriverMonad m context) | |
| => ExampleT (LabelValue "webdriverSession" WebDriverSession :> context) m a | Wrapped action |
| -> ExampleT context m a |
Convenience function. withSession1 = withSession "session1".
Arguments
| :: (MonadMask m, MonadBaseControl IO m, HasBaseContext context, HasSomeCommandLineOptions context, WebDriverMonad m context) | |
| => ExampleT (LabelValue "webdriverSession" WebDriverSession :> context) m a | Wrapped action |
| -> ExampleT context m a |
Convenience function. withSession2 = withSession "session2".
Managing sessions
getSessions :: (MonadReader context m, WebDriverMonad m context) => m [Session] Source #
Get all existing session names.
closeCurrentSession :: (MonadLogger m, WebDriverSessionMonad m context) => m () Source #
Close the current session.
closeSession :: (HasCallStack, MonadLogger m, MonadUnliftIO m) => Session -> WebDriver -> m () Source #
Close the given session.
closeAllSessions :: (HasCallStack, MonadLogger m, MonadUnliftIO m) => WebDriver -> m () Source #
Close all sessions.
closeAllSessionsExcept :: (HasCallStack, MonadLogger m, MonadUnliftIO m) => [Session] -> WebDriver -> m () Source #
Close all sessions except those listed.
Lower-level allocation functions
Arguments
| :: (BaseMonad m context, HasFile context "java", HasFile context "selenium.jar", HasBrowserDependencies context) | |
| => WdOptions | Options |
| -> OnDemandOptions | |
| -> ExampleT context m WebDriver |
Allocate a WebDriver using the given options.
cleanupWebDriver :: BaseMonad m context => WebDriver -> ExampleT context m () Source #
Clean up the given WebDriver.
introduceBrowserDependenciesViaNix Source #
Arguments
| :: forall m context. (MonadUnliftIO m, HasBaseContext context, HasNixContext context, HasSomeCommandLineOptions context) | |
| => SpecFree (LabelValue "browserDependencies" BrowserDependencies :> context) m () | Child spec |
| -> SpecFree context m () | Parent spec |
Introduce BrowserDependencies via Nix, using the command line options.
This is useful to create the context for functions like allocateWebDriver.
introduceBrowserDependenciesViaNix' Source #
Arguments
| :: forall m context. (MonadUnliftIO m, HasBaseContext context, HasNixContext context, HasSomeCommandLineOptions context) | |
| => NodeOptions | |
| -> SpecFree (LabelValue "browserDependencies" BrowserDependencies :> context) m () | Child spec |
| -> SpecFree context m () | Parent spec |
Same as introduceBrowserDependenciesViaNix, but allows passing custom NodeOptions.
Arguments
| :: forall m context. BaseMonad m context | |
| => WebDriverDependencies | Dependencies |
| -> (WdOptions -> ExampleT (ContextWithBaseDeps context) m WebDriver) | |
| -> WdOptions | |
| -> SpecFree (ContextWithWebdriverDeps context) m () | |
| -> SpecFree context m () |
Same as introduceWebDriver, but with a controllable allocation callback.
addCommandLineOptionsToWdOptions :: SomeCommandLineOptions -> WdOptions -> WdOptions Source #
Merge the options from the CommandLineOptions into some WdOptions.
Context types
WebDriver
type HasWebDriverContext context = HasLabel context "webdriver" WebDriver Source #
WebDriverSession
webdriverSession :: Label "webdriverSession" WebDriverSession Source #
type HasWebDriverSessionContext context = HasLabel context "webdriverSession" WebDriverSession Source #
Shorthands
These are used to make type signatures shorter.
type BaseMonad m context = (HasCallStack, MonadUnliftIO m, MonadMask m, HasBaseContext context) Source #
type ContextWithBaseDeps context Source #
Arguments
| = LabelValue "browserDependencies" BrowserDependencies :> (FileValue "java" :> (FileValue "selenium.jar" :> context)) | Browser dependencies |
type ContextWithWebdriverDeps context = LabelValue "webdriver" WebDriver :> ContextWithBaseDeps context Source #
type WebDriverMonad m context = (HasCallStack, MonadUnliftIO m, HasWebDriverContext context) Source #
type WebDriverSessionMonad m context = (WebDriverMonad m context, MonadReader context m, HasWebDriverSessionContext context) Source #
On demand options
data OnDemandOptions Source #
How to obtain certain binaries "on demand". These may or not be needed based on WdOptions, so
they will be obtained as needed.