Created
October 24, 2017 00:49
-
-
Save jhrcek/f9118a9bf6d9c53c327e451961358135 to your computer and use it in GitHub Desktop.
Demonstration of how Haskell's WebDriver library can be used Interactively in GHCi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
import Test.WebDriver.Commands (Selector (ById, ByName), click, closeSession, | |
findElem, openPage, sendKeys) | |
import Test.WebDriver.Config (defaultConfig) | |
import Test.WebDriver.Monad (runSession, runWD) | |
import Test.WebDriver.Session (getSession) | |
-- These commands can be executed one by one in GHCi | |
-- (! Note that this is not a recommended way to use webdriver library | |
-- normally you'd use runSession to hide explicit session handling !) | |
-- Prerequisite: Standalone selenium server is running in the background | |
-- e.g. $ java -jar selenium-server-standalone-2.53.0.jar | |
interactiveDemo :: IO () | |
interactiveDemo = do | |
s <- runSession defaultConfig getSession | |
runWD s $ openPage "https://www.google.cz" | |
searchInput <- runWD s . findElem $ ById "lst-ib" | |
runWD s $ sendKeys "Haskell" searchInput | |
searchButton <- runWD s . findElem $ ByName "btnK" | |
runWD s $ click searchButton | |
runWD s closeSession |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment