{-# LANGUAGE OverloadedStrings #-}
module Main where
import Web.Api.WebDriver.Endpoints
import Web.Api.WebDriver
main :: IO ()
main = do
x <- execWebDriverT defaultWebDriverConfig doLogin
print x
doLogin :: WebDriverT IO ()
doLogin = do
fullscreenWindow
navigateTo "http://localhost:8001/login"
z <- findElements CssSelector "div.alert"
assertEqual [] z "Errors found"
The above code results in an error of:
2021-12-13 16:32:39 ERROR Error No session in progress (Left (E NoSession),S {_httpOptions = Options { manager = Left _, proxy = Nothing, auth = Nothing, headers = [("User-Agent","haskell wreq-0.5.3.2")], params = [], redirects = 10, cookies = Just (CJ {expose = []}) }, _httpSession = Nothing, _userState = WDState {_sessionId = Nothing, _breakpoints = BreakpointsOff}},W {unW = [LogEntry {_logEntryTimestamp = 2021-12-13 16:32:39.03282154 UTC, _logEntryUID = "", _logEntrySeverity = LogError, _logEntry = L_Error NoSession}]})
What does this error indicate? What am I missing?
Full example project can be found here: https://github.com/chrissound/434/commit/ea1f3d840b64093b40ebba0e3dfceaacd4b36716
The error indicates no session has been initialized on the 'webdriver'.
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).
https://www.w3.org/TR/webdriver/#sessions
A session can be created/managed with:
x <- execWebDriverT defaultWebDriverConfig $
runIsolated defaultFirefoxCapabilities doLogin
Instead of x <- execWebDriverT defaultWebDriverConfig doLogin
.
Seems like runIsolated
takes care of all the session handling.