webdriver 0.6.0.1 → 0.6.0.2
raw patch · 4 files changed
+24/−16 lines, 4 filesdep +network-uridep ~aesondep ~attoparsecdep ~bytestring
Dependencies added: network-uri
Dependency ranges changed: aeson, attoparsec, bytestring, directory-tree, exceptions, network
Files
- README.md +4/−4
- src/Test/WebDriver/Internal.hs +5/−5
- test/search-baidu.hs +1/−1
- webdriver.cabal +14/−6
README.md view
@@ -61,7 +61,7 @@ myConfig = defaultConfig main :: IO ()- main = runSession config $ do+ main = runSession myConfig $ do openPage "http://google.com" searchInput <- findElem (ByCSS "input[type='text']") sendKeys "Hello, World!" searchInput@@ -88,12 +88,12 @@ To configure a new WebDriver session, we use the `WDConfig` type; this is a record type with various configuration fields. To connect to the Selenium server that we spawned earlier, the `defaultConfig` is sufficient. By default, the browser is set to Firefox, but that can be changed; the following configuration will use Google Chrome instead of Firefox for our test: myConfig :: WDConfig- myConfig = defaultConfig { wdCapabilities = chrome }+ myConfig = defaultConfig { wdCapabilities = defaultCaps { browser = chrome } } ###Initializing tests main :: IO ()- main = runSession config $ do+ main = runSession myConfig $ do `main` is the standard entry point for a Haskell program, defined as a value of type `IO a`. In order to transform our `WD` action into an `IO` action, we use the `runSession` function, which has the type: @@ -103,7 +103,7 @@ NOTE: `runSession` does not automatically close the session it creates. This is intentional, as you may want to manually inspect the browser state after your code executes. If you want to have the session automatically close, you can use the `finallyClose` function to provide this behavior. - main = runSession config . finallyClose $ do+ main = runSession myConfig . finallyClose $ do ###Actually writing tests!
src/Test/WebDriver/Internal.hs view
@@ -29,7 +29,7 @@ import qualified Data.Text.Encoding as TE import qualified Data.Text.Lazy.Encoding as TLE import Data.ByteString.Lazy.Char8 (ByteString)-import Data.ByteString.Lazy.Char8 as LBS (length, unpack, null)+import Data.ByteString.Lazy.Char8 as LBS (length, unpack, null, fromStrict) import qualified Data.ByteString.Char8 as BS import qualified Data.ByteString.Base64.Lazy as B64 @@ -61,6 +61,7 @@ , requestHeaders = headers ++ [ (hAccept, "application/json;charset=UTF-8") , (hContentType, "application/json;charset=UTF-8") , (hContentLength, fromString . show . LBS.length $ body) ]+ , checkStatus = \_ _ _ -> Nothing -- all status codes handled by getJSONResult , method = meth } -- |Sends an HTTP request to the remote WebDriver server@@ -83,8 +84,9 @@ | code >= 500 && code < 600 = case lookup hContentType headers of Just ct- | "application/json;" `BS.isInfixOf` ct ->- parseJSON' body+ | "application/json" `BS.isInfixOf` ct ->+ parseJSON' + (maybe body LBS.fromStrict $ lookup "X-Response-Body-Start" headers) >>= handleJSONErr >>= maybe noReturn returnErr | otherwise -> @@ -171,7 +173,6 @@ 34 -> e MoveTargetOutOfBounds 51 -> e InvalidXPathSelector 52 -> e InvalidXPathSelectorReturnType- 405 -> e MethodNotAllowed _ -> e UnknownError @@ -247,7 +248,6 @@ | MoveTargetOutOfBounds | InvalidXPathSelector | InvalidXPathSelectorReturnType- | MethodNotAllowed deriving (Eq, Ord, Enum, Bounded, Show) -- |Detailed information about the failed command provided by the server.
test/search-baidu.hs view
@@ -28,7 +28,7 @@ title <- getTitle return ("cheese!" `T.isSuffixOf` title) -testCase c = void $ runSession defaultConfig c (baidu >> searchBaidu)+testCase c = void $ runSession (defaultConfig { wdCapabilities = c }) (baidu >> searchBaidu) testSuits = mapM_ testCase [capsFF, capsChrome]
webdriver.cabal view
@@ -1,5 +1,5 @@ Name: webdriver-Version: 0.6.0.1+Version: 0.6.0.2 Cabal-Version: >= 1.8 License: BSD3 License-File: LICENSE@@ -25,18 +25,21 @@ source-repository head type: git location: git://github.com/kallisti-dev/hs-webdriver.git+ +flag network-uri+ description: Get Network.URI from the network-uri package+ default: True library hs-source-dirs: src ghc-options: -Wall build-depends: base == 4.*- , aeson >= 0.6.2.0 && < 0.8- , network >= 2.4 && < 2.6+ , aeson >= 0.6.2.0 && < 0.9 , http-client >= 0.3 && < 0.4 , http-types >= 0.8 && < 0.9 , text >= 0.11.3 && < 1.2.0.0 , bytestring >= 0.9 && < 0.11- , attoparsec < 0.12+ , attoparsec < 0.13 , base64-bytestring >= 1.0 && < 1.1 , mtl >= 2.0 && < 2.3 , transformers >= 0.2 && < 0.5@@ -46,15 +49,20 @@ , zip-archive >= 0.1.1.8 && < 0.3 , directory == 1.* , filepath == 1.*- , directory-tree == 0.11.*+ , directory-tree >= 0.11 && < 0.13 , temporary >= 1.0 && < 2.0 , time == 1.* , unordered-containers >= 0.1.3 && < 0.4 , vector >= 0.3 && < 0.11- , exceptions >= 0.4 && < 0.6+ , exceptions >= 0.4 && < 0.7 , scientific >= 0.2 && < 0.4 , data-default >= 0.2 && < 1.0 , cond >= 0.3 && < 0.5+ + if flag(network-uri)+ build-depends: network-uri >= 2.6, network >= 2.6+ else+ build-depends: network-uri < 2.6, network >= 2.4 && < 2.6 exposed-modules: Test.WebDriver Test.WebDriver.Class