Skip to content

Commit

Permalink
Added phantomJS, #94
Browse files Browse the repository at this point in the history
  • Loading branch information
lefthandedgoat committed Aug 30, 2013
1 parent 50de294 commit 93b3c3a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 36 deletions.
70 changes: 36 additions & 34 deletions basictests/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ open runner
open configuration
open reporters

start firefox
start chrome
let mainBrowser = browser
elementTimeout <- 3.0
compareTimeout <- 3.0
Expand Down Expand Up @@ -281,39 +281,6 @@ before (fun _ -> Console.WriteLine "only before set now")
url testpage
"#firstName" == "John1")

context "alert tests"
before (fun _ -> !^ "http://lefthandedgoat.github.io/canopy/testpages/alert")

"alert box should have 'Alert Test'" &&& (fun _ ->
click "#alert_test"
alert() == "Alert Test"
acceptAlert())

"alert box should have 'Alert Test'" &&& (fun _ ->
click "#alert_test"
alert() == "Alert Test"
dismissAlert())

"alert box should fail correctly when expecting wrong message" &&& (fun _ ->
failsWith "equality check failed. expected: Not the message, got: Alert Test"
click "#alert_test"
alert() == "Not the message")

"confirmation box should have 'Confirmation Test'" &&& (fun _ ->
click "#confirmation_test"
alert() == "Confirmation Test"
acceptAlert())

"confirmation box should have 'Confirmation Test'" &&& (fun _ ->
click "#confirmation_test"
alert() == "Confirmation Test"
dismissAlert())

"confirmation box should fail correctly when expecting wrong message" &&& (fun _ ->
failsWith "equality check failed. expected: Not the message, got: Confirmation Test"
click "#confirmation_test"
alert() == "Not the message")

context "other tests"

"define a custom wait for using any function that takes in unit and returns bool" &&& (fun _ ->
Expand Down Expand Up @@ -406,6 +373,41 @@ context "dragging"
click "#task_editor_buttons .save_button"
".handle" --> ".inprogress")

if not (browser :? OpenQA.Selenium.PhantomJS.PhantomJSDriver) then
context "alert tests"

before (fun _ -> !^ "http://lefthandedgoat.github.io/canopy/testpages/alert")

"alert box should have 'Alert Test'" &&& (fun _ ->
click "#alert_test"
alert() == "Alert Test"
acceptAlert())

"alert box should have 'Alert Test'" &&& (fun _ ->
click "#alert_test"
alert() == "Alert Test"
dismissAlert())

"alert box should fail correctly when expecting wrong message" &&& (fun _ ->
failsWith "equality check failed. expected: Not the message, got: Alert Test"
click "#alert_test"
alert() == "Not the message")

"confirmation box should have 'Confirmation Test'" &&& (fun _ ->
click "#confirmation_test"
alert() == "Confirmation Test"
acceptAlert())

"confirmation box should have 'Confirmation Test'" &&& (fun _ ->
click "#confirmation_test"
alert() == "Confirmation Test"
dismissAlert())

"confirmation box should fail correctly when expecting wrong message" &&& (fun _ ->
failsWith "equality check failed. expected: Not the message, got: Confirmation Test"
click "#confirmation_test"
alert() == "Not the message")

context "tiling windows"
"start multiple browsers and tile them" &&& (fun _ ->
start chrome
Expand Down
7 changes: 6 additions & 1 deletion canopy/canopy.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ type BrowserStartMode =
| Chrome
| ChromeWithOptions of Chrome.ChromeOptions
| ChromeWithOptionsAndTimeSpan of Chrome.ChromeOptions * TimeSpan
| PhantomJS

let firefox = Firefox
let ie = IE
let chrome = Chrome

let phantomJS = PhantomJS

let mutable browsers = []

Expand Down Expand Up @@ -510,6 +511,7 @@ let start b =
//for ie you need to set Settings -> Advance -> Security Section -> Check-Allow active content to run files on My Computer*
//also download IEDriverServer and place in c:\ or configure with ieDir
//firefox just works
//for phantomjs download it and put in c:\ or configure with phantomJSDir
browser <-
match b with
| IE ->
Expand All @@ -528,6 +530,9 @@ let start b =
new OpenQA.Selenium.Firefox.FirefoxDriver() :> IWebDriver
| FirefoxWithProfile profile ->
new OpenQA.Selenium.Firefox.FirefoxDriver(profile) :> IWebDriver
| PhantomJS ->
new OpenQA.Selenium.PhantomJS.PhantomJSDriver(phantomJSDir) :> IWebDriver

if autoPinBrowserRightOnLaunch = true then pin Right
browsers <- browsers @ [browser]

Expand Down
1 change: 1 addition & 0 deletions canopy/configuration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ let failFast = ref false

let mutable chromeDir = @"c:\"
let mutable ieDir = @"c:\"
let mutable phantomJSDir = @"c:\"
let mutable elementTimeout = 10.0
let mutable compareTimeout = 10.0
let mutable pageTimeout = 10.0
Expand Down

This file was deleted.

Binary file not shown.

0 comments on commit 93b3c3a

Please sign in to comment.