{-# LANGUAGE OverloadedStrings #-} module Test.Google where import Control.Monad import qualified Data.Text as T import Test.WebDriver import DarcsDen.Settings (baseUrl) -- make sure the app is approved for this -- account before calling this function googleLogin :: String -> String -> WD () googleLogin user pass = do elems <- mapM (findElem.ById) ["Email", "Passwd"] mapM_ (uncurry sendKeys) (zip (map T.pack [user, pass]) elems) (findElem.ById $ "signIn") >>= click na <- fmap ((==baseUrl).take (length baseUrl)) getCurrentURL unless na $ -- findElem is not working here, so you -- need to approve access manually once (findElem.ById $ "submit_approve_access") >>= click googleRegSelector :: T.Text googleRegSelector = ".buttons > input[value=\"Sign up with Google\"]" googleSyncSelector :: T.Text googleSyncSelector = ".buttons > input[value=\"Link with Google\"]" googleLoginSelector :: T.Text googleLoginSelector = ".buttons > input[value=\"Sign in using Google\"]"