To run the example tests in this repo, do the following.
cd into elm-webdriver/testyarn && yarn testIf you get an error similar to Problem with Webdriver host (Unable
to make a connection. Is your network working?), you may need to
run ChromeDriver manually. Go
here and find
where it describes how to 'Start the ChromeDriver server
separately'.
WebDriver is a remote control interface that enables introspection and control of user agents. It provides a platform- and language-neutral wire protocol as a way for out-of-process programs to remotely instruct the behavior of web browsers.
elm-webdriver is framework that allows write scripts for WebDriver with plain Node.js runner that just executes compiled elm
import Task
import WebDriver
import WebDriver.Runner exposing (TestRunner, run)
suite : WebDriver.Test
suite =
describe "Web Page Navigate"
[ test "star elm-webdriver" <|
\{ url, element, attribute } ->
url "https://github.com/justgook/elm-webdriver"
|> Task.andThen (\_ -> "h1" |> Selector.css |> element)
|> Task.andThen (.value >> attribute "innerText")
|> Task.andThen (.value >> Expect.equal "justgook/elm-webdriver")
]
main : TestRunner
main = run suiteNote: To be able run from node you need install
XMLHttpRequestreplacement (node don't have build in). Installxhr2and append it:
var XMLHttpRequest = require(\"xhr2\");
compile Your tests
elm-make Main.elm --output=bundle.js
and run compiled code
node -e 'var XMLHttpRequest = require(\"xhr2\"); require(\"./bundle.js\").Main.worker().ports.log.subscribe((a)=>process.stdout.write(a))'