diff --git a/src/canopy/canopy.fs b/src/canopy/canopy.fs index 9956e680..d90c8bd2 100644 --- a/src/canopy/canopy.fs +++ b/src/canopy/canopy.fs @@ -741,6 +741,17 @@ let title() = browser.Title let reload = currentUrl >> url +type Navigate = + | Back + | Forward + +let back = Back +let forward = Forward + +let navigate = function + | Back -> browser.Navigate().Back() + | Forward -> browser.Navigate().Forward() + let coverage (url : 'a) = let mutable innerUrl = "" match box url with diff --git a/tests/basictests/Program.fs b/tests/basictests/Program.fs index 200b923e..9c333244 100644 --- a/tests/basictests/Program.fs +++ b/tests/basictests/Program.fs @@ -588,16 +588,22 @@ context "User Agents tests" start <| ChromeWithUserAgent userAgents.iPad url "http://whatsmyuseragent.com/" ".info" *~ "iPad" + quit browser + switchTo mainBrowser "FirefoxDeviceWithUserAgent userAgents.iPhone should show as iPhone" &&& fun _ -> start <| FirefoxWithUserAgent userAgents.iPhone url "http://whatsmyuseragent.com/" ".info" *~ "iPhone" + quit browser + switchTo mainBrowser "FirefoxDeviceWithUserAgent myagent should show as myagent" &&& fun _ -> start <| FirefoxWithUserAgent "myagent" url "http://whatsmyuseragent.com/" ".info" *~ "myagent" + quit browser + switchTo mainBrowser context "Resize tests" @@ -607,6 +613,8 @@ context "Resize tests" resize (400,400) "#cWidth" == "400" "#cHeight" == "400" + quit browser + switchTo mainBrowser "Chrome should be resized to iPhone4" &&& fun _ -> start chrome @@ -614,6 +622,8 @@ context "Resize tests" resize screenSizes.iPhone4 "#cWidth" == "320" "#cHeight" == "480" + quit browser + switchTo mainBrowser "Firefox should be resized to 400,500 then rotated to 500,400" &&& fun _ -> start firefox @@ -622,6 +632,8 @@ context "Resize tests" rotate() "#cHeight" == "400" "#cWidth" == "500" + quit browser + switchTo mainBrowser "Chrome should be resized and rotated to iPhone4" &&& fun _ -> start chrome @@ -630,6 +642,8 @@ context "Resize tests" rotate() "#cHeight" == "320" "#cWidth" == "480" + quit browser + switchTo mainBrowser context "pluggable finders tests" @@ -648,6 +662,16 @@ addFinder findByHref click "actions.html" on "http://lefthandedgoat.github.io/canopy/actions.html" +context "Navigate tests" + +"Browser should navigate back and forward" &&& fun _ -> + url "http://lefthandedgoat.github.io/canopy/index.html" + click "actions.html" + navigate back + on "http://lefthandedgoat.github.io/canopy/index.html" + navigate forward + on "http://lefthandedgoat.github.io/canopy/actions.html" + context "todo tests" "write a test that tests the whole internet!" &&& todo