Skip to content
This repository has been archived by the owner on Jan 17, 2020. It is now read-only.

Commit

Permalink
Upgrade to use PureScript 0.9.1 and update all dependencies (#45)
Browse files Browse the repository at this point in the history
Upgrade to use PureScript 0.9.1 and update all dependencies
  • Loading branch information
daniel-chambers authored and cryogenian committed Jul 19, 2016
1 parent c322bdb commit be00df3
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 37 deletions.
8 changes: 4 additions & 4 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
],
"license": "Apache-2.0",
"dependencies": {
"purescript-aff": "^0.16.0",
"purescript-aff-reattempt": "^0.3.0",
"purescript-base": "^0.2.0",
"purescript-dom": "^0.2.4"
"purescript-aff": "^1.0.0",
"purescript-aff-reattempt": "^1.0.0",
"purescript-base": "^1.0.0",
"purescript-dom": "^1.1.0"
}
}
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
"private": true,
"scripts": {
"clean": "rimraf output && rimraf .pulp-cache",
"build": "pulp build"
"build": "pulp build",
"bower": "bower"
},
"devDependencies": {
"pulp": "^8.1.0",
"purescript": "^0.7.6",
"rimraf": "^2.5.2"
"pulp": "^9.0.1",
"purescript": "^0.9.1",
"rimraf": "^2.5.3",
"bower": "^1.7.1"
}
}
4 changes: 2 additions & 2 deletions src/Selenium.purs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import Data.Maybe (Maybe())
import Data.Either (either)
import Control.Monad.Aff (Aff(), attempt)
import Selenium.Types
import Data.Unfoldable (Unfoldable, unfoldr)
import Data.Unfoldable (class Unfoldable, unfoldr)
import Data.Foreign (Foreign())
import Data.Maybe (Maybe(..))
import Data.Array (uncons)
Expand Down Expand Up @@ -116,7 +116,7 @@ loseElement driver locator = do
result <- attempt $ findExact driver locator
either (const $ pure unit) (const $ throwError $ error failMessage) result
where
failMessage = "Found element with locator: " ++ showLocator locator
failMessage = "Found element with locator: " <> showLocator locator

-- | Finds elements by locator from `document`
findElements :: forall e f. (Unfoldable f) => Driver -> Locator -> Aff (selenium :: SELENIUM|e) (f Element)
Expand Down
2 changes: 1 addition & 1 deletion src/Selenium/ActionSequence.purs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Prelude
import Selenium.Types
import Selenium.MouseButton
import Data.List
import Data.Function
import Data.Function.Uncurried
import Data.Foldable (foldl)
import Control.Monad.Writer (Writer(), execWriter)
import Control.Monad.Writer.Class (tell)
Expand Down
2 changes: 1 addition & 1 deletion src/Selenium/Builder.purs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Selenium.Types
import Selenium.Browser
import Data.Tuple
import Data.List
import Data.Function
import Data.Function.Uncurried
import Data.Foldable (foldl)
import Control.Monad.Writer (Writer(), execWriter)
import Control.Monad.Writer.Class (tell)
Expand Down
5 changes: 2 additions & 3 deletions src/Selenium/Combinators.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Prelude
import Control.Alt ((<|>))
import Control.Monad.Trans (lift)
import Data.Maybe (Maybe(), isJust, maybe)
import Data.Maybe.Unsafe (fromJust)
import Data.Either (Either(..), either)
import Control.Monad.Error.Class (throwError)
import Control.Monad.Eff.Exception (error)
Expand Down Expand Up @@ -33,7 +32,7 @@ tryFind probablyLocator =
waitUntilJust :: forall e o a. Selenium e o (Maybe a) -> Int -> Selenium e o a
waitUntilJust check time = do
wait (checker $ isJust <$> check) time
fromJust <$> check
check >>= maybe (throwError $ error $ "Maybe was not Just after waiting for isJust") pure

-- Tries to evaluate `Selenium` if it returns `false` after 500ms
checker :: forall e o. Selenium e o Boolean -> Selenium e o Boolean
Expand Down Expand Up @@ -81,4 +80,4 @@ await timeout check = do
Right _ -> pure unit

awaitUrlChanged :: forall e o. String -> Selenium e o Boolean
awaitUrlChanged oldURL = checker $ (oldURL /=) <$> getCurrentUrl
awaitUrlChanged oldURL = checker $ (oldURL /= _) <$> getCurrentUrl
12 changes: 6 additions & 6 deletions src/Selenium/Monad.purs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import Control.Monad.Eff.Console (CONSOLE())
import Control.Monad.Eff.Ref (REF())
import Control.Monad.Reader.Trans
import Control.Monad.Reader.Class
import qualified Control.Monad.Aff as A
import qualified Control.Monad.Aff.Reattempt as A
import qualified Selenium as S
import qualified Selenium.ActionSequence as S
import qualified Selenium.XHR as S
import Control.Monad.Aff as A
import Control.Monad.Aff.Reattempt as A
import Selenium as S
import Selenium.ActionSequence as S
import Selenium.XHR as S
-- | `Driver` is field of `ReaderT` context
-- | Usually selenium tests are run with tons of configs (i.e. xpath locators,
-- | timeouts) all those configs can be putted to `Selenium e o a`
Expand Down Expand Up @@ -236,7 +236,7 @@ clearLog :: forall e o. Selenium e o Unit
clearLog = getDriver >>= S.clearLog >>> lift

getXHRStats :: forall e o. Selenium e o (List XHRStats)
getXHRStats = getDriver >>= S.getStats >>> map toList >>> lift
getXHRStats = getDriver >>= S.getStats >>> map fromFoldable >>> lift


getWindowHandle :: forall e o. Selenium e o WindowHandle
Expand Down
2 changes: 1 addition & 1 deletion src/Selenium/Types.purs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Selenium.Types where

import Prelude
import Data.Foreign.Class (IsForeign)
import Data.Foreign.Class (class IsForeign)
import Data.Foreign (readString, ForeignError(..))
import Data.String (toLower)
import Data.Either (Either(..))
Expand Down
27 changes: 12 additions & 15 deletions src/Selenium/XHR.purs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import Control.Monad.Error.Class (throwError)
import Control.Monad.Eff.Exception (error)
import Data.Foreign (readBoolean, isUndefined, readArray)
import Data.Foreign.Class (readProp)
import Data.Foreign.NullOrUndefined (runNullOrUndefined)
import Data.Foreign.NullOrUndefined (unNullOrUndefined)

-- | Start spy on xhrs. It defines global variable in browser
-- | and put information about to it.
-- | and put information about to it.
startSpying :: forall e. Driver -> Aff (selenium :: SELENIUM|e) Unit
startSpying driver = void $
startSpying driver = void $
executeStr driver """
"use strict"
// If we have activated spying
Expand Down Expand Up @@ -52,13 +52,13 @@ if (window.__SELENIUM__) {
var send = XMLHttpRequest.prototype.send;
window.XMLHttpRequest.prototype.send =
function(data) {
// this request can be deleted (this.clean() i.e.)
// this request can be deleted (this.clean() i.e.)
if (Selenium.log[this.__id]) {
Selenium.log[this.__id].state = "opened";
}
// monkey pathc `onload` (I suppose it's useless to fire xhr
// without `onload` handler, but to be sure there is check for
// type of current value
// type of current value
var m = this.onload;
this.onload = function() {
if (Selenium.log[this.__id]) {
Expand All @@ -70,7 +70,7 @@ if (window.__SELENIUM__) {
};
send.apply(this, arguments);
};
// monkey patch `abort`
// monkey patch `abort`
var abort = window.XMLHttpRequest.prototype.abort;
window.XMLHttpRequest.prototype.abort = function() {
if (Selenium.log[this.__id]) {
Expand All @@ -79,7 +79,7 @@ if (window.__SELENIUM__) {
abort.apply(this, arguments);
};
this.isActive = true;
// if we define it here we need not to make `send` global
// if we define it here we need not to make `send` global
Selenium.unspy = function() {
this.active = false;
window.XMLHttpRequest.send = send;
Expand All @@ -106,8 +106,8 @@ if (window.__SELENIUM__) {
"""

-- | Clean log. Will raise an error if spying hasn't been initiated
clearLog :: forall e. Driver -> Aff (selenium :: SELENIUM|e) Unit
clearLog driver = do
clearLog :: forall e. Driver -> Aff (selenium :: SELENIUM|e) Unit
clearLog driver = do
success <- executeStr driver """
if (!window.__SELENIUM__) {
return false;
Expand All @@ -123,7 +123,7 @@ clearLog driver = do

-- | Get recorded xhr stats. If spying has not been set will raise an error
getStats :: forall e. Driver -> Aff (selenium :: SELENIUM|e) (Array XHRStats)
getStats driver = do
getStats driver = do
log <- executeStr driver """
if (!window.__SELENIUM__) {
return undefined;
Expand All @@ -142,15 +142,12 @@ getStats driver = do
method <- readProp "method" el
url <- readProp "url" el
async <- readProp "async" el
password <- runNullOrUndefined <$> readProp "password" el
user <- runNullOrUndefined <$> readProp "user" el
password <- unNullOrUndefined <$> readProp "password" el
user <- unNullOrUndefined <$> readProp "user" el
pure { state: state
, method: method
, url: url
, async: async
, password: password
, user: user
}



0 comments on commit be00df3

Please sign in to comment.