{-# LANGUAGE OverloadedStrings #-} module Test.Github where import Control.Monad import qualified Data.Text as T import Test.WebDriver import DarcsDen.Settings (baseUrl) githubLogin :: String -> String -> WD () githubLogin user pass = do elems <- mapM (findElem.ById) ["login_field", "password"] mapM_ (uncurry sendKeys) (zip (map T.pack [user, pass]) elems) (findElem.ByName $ "commit") >>= click na <- fmap ((==baseUrl).take (length baseUrl)) getCurrentURL unless na $ (findElem.ByName $ "authorize") >>= click githubRegSelector :: T.Text githubRegSelector = ".buttons > input[value=\"Sign up with Github\"]" githubSyncSelector :: T.Text githubSyncSelector = ".buttons > input[value=\"Link with Github\"]" githubLoginSelector :: T.Text githubLoginSelector = ".buttons > input[value=\"Sign in using Github\"]"