haskell-webdriver / haskell-webdriver

A Haskell client for the Selenium WebDriver protocol.
http://hackage.haskell.org/package/webdriver
BSD 3-Clause "New" or "Revised" License
191 stars 72 forks source link

include facility for managing selenium process #173

Open eflister opened 3 years ago

eflister commented 3 years ago

it would be nice to offer a recommended way to automate the selenium process:

withCreateProcess (shell "java -jar selenium-server-standalone-*.jar") {std_err = CreatePipe} $ \_ _ stderr ph -> -- proc denies permission?
  flip (maybe $ error "no stderr") stderr $ \s -> do -- is there a way to use the monad instance of maybe instead of explicitly checking?
    os <- whileM (catchIOError (hWaitForInput s $ 3*10^3) $ \e -> if isEOFError e then return False else ioError e) $ do -- hIsEOF can block
      o <- hGetLine s
      putStrLn o
      return $ isInfixOf "up and running" o
    print os
    unless (or os) $ error "selenium didn't start"

    runSession (useBrowser chrome defaultConfig) . finallyClose $ do
      ...