Skip to content

Commit

Permalink
Merge pull request #214 from JeremyBellows/issue213-configurableMessa…
Browse files Browse the repository at this point in the history
…geOnBrowser

Issue213 configurable message on browser
  • Loading branch information
lefthandedgoat committed Sep 9, 2015
2 parents bb07905 + 21778b6 commit 410f3f4
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 11 deletions.
3 changes: 2 additions & 1 deletion canopy.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30324.0
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{51B54B14-A7C3-450B-A722-159E9CD3010F}"
ProjectSection(SolutionItems) = preProject
Expand Down Expand Up @@ -35,6 +35,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{A94D
ProjectSection(SolutionItems) = preProject
docs\content\actions.fsx = docs\content\actions.fsx
docs\content\assertions.fsx = docs\content\assertions.fsx
docs\content\configuration.fsx = docs\content\configuration.fsx
docs\content\index.fsx = docs\content\index.fsx
docs\content\reporting.fsx = docs\content\reporting.fsx
docs\content\testing.fsx = docs\content\testing.fsx
Expand Down
171 changes: 171 additions & 0 deletions docs/content/configuration.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
(*** hide ***)
// This block of code is omitted in the generated HTML documentation. Use
// it to define helpers that you do not want to show in the documentation.
#I "../../bin"
#r "canopy.dll"
#r "WebDriver.dll"
open canopy
open canopy.configuration


(**
Configuration
========================
chromeDir
--
Directory for the chromedriver.
Defaults to pre-set OS paths
OSX: /usr/bin/
Windows: C:\
*)
chromeDir <- "C:\\"

(**
ieDir
--------
Directory for Internet Explorer.
Defaults to pre-set OS paths
OSX: /usr/bin/
Windows: C:\
*)
ieDir <- "C:\\"

(**
phantomJSDir
----------
Directory for phantomJS
Defaults to pre-set OS paths
OSX: /usr/bin/
Windows: C:\
*)
phantomJSDir <- "C:\\"

(**
safariDir
-----------
Directory for Safari
Defaults to pre-set OS paths
OSX: /usr/bin/
Windows: C:\
*)
safariDir <- "C:\\"

(**
elementTimeout
-------------------
Amount of time for the test runner to search for an element.
Default is 10.0 seconds
*)
elementTimeout <- 10.0

(**
compareTimeout
-----------------------
Amount of time for the test runner to spend comparing elements.
Default is 10.0 seconds
*)
compareTimeout <- 10.0

(**
pageTimeout
-----------------
Amount of time for the test runner to wait for the page to load.
Default is 10.0 seconds
*)
pageTimeout <- 10.0

(**
wipSleep
--------
Amount of time to spend between WIP tests (Tests marked with &&&&)
Default is 1.0 seconds
*)
wipSleep <- 1.0

(**
runFailedContextsFirst
-----
Runs failed contexts first if the test suite has already executed.
Defaults is false
*)
runFailedContextsFirst <- false

(**
reporter
----------------
Reporter object that will handle how logs should be stored.
Must inherit IReporter
Default is ConsoleReporter
*)
reporter <- new reporters.ConsoleReporter() :> reporters.IReporter

(**
disableSuggestOtherSelectors
----------------------------
Option that will disable selector suggestion if a selector fails to execute
Defaults is false
*)
disableSuggestOtherSelectors <- false

(**
autoPinBrowserRightOnLaunch
---------
Automatically pins the browser to the right of the screen on launch
Default is true
*)
autoPinBrowserRightOnLaunch <- true

(**
throwIfMoreThanOneElement
------------
Throws a CanopyMoreThanOneElementFoundException if more than one element is found using a selector
Default is false
*)
throwIfMoreThanOneElement <- false

(**
configuredFinders
------------
Defines functions for finding elements based on selectors
Default is the following sequence
findByCss
findByValue
findByXpath
findByLabel
findByText
findByJQuery
*)
configuredFinders <- finders.defaultFinders

(**
writeToSelectWithOptionValue
------------
TODO
Default is true
*)
writeToSelectWithOptionValue <- true

(**
optimizeBySkippingIFrameCheck
------------
TODO
Default is false
*)
optimizeBySkippingIFrameCheck <- false

(**
optimizeByDisablingCoverageReport
------------
TODO
Default is false
*)
optimizeByDisablingCoverageReport <- false

(**
showInfoDiv
------------
Allows information to be displayed on the browser when the puts function is called
Default is true
*)
showInfoDiv <- true
1 change: 1 addition & 0 deletions docs/content/index.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ quit()
* [Actions](/canopy/actions.html): documentation of everything you can do on a page
* [Assertions](/canopy/assertions.html): all the ways you can verify what's on the page is correct
* [Configuration](/canopy/configuration.html): configure and fine tune canopy
* [Testing](/canopy/testing.html): different ways to orchestrate tests and troubleshoot issues with a page
* [Reporting](/canopy/reporting.html): different ways to output the results of your test suite
Expand Down
19 changes: 10 additions & 9 deletions src/canopy/canopy.fs
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,16 @@ let sleep seconds =

let puts text =
reporter.write text
let escapedText = System.Web.HttpUtility.JavaScriptStringEncode(text)
let info = "
var infoDiv = document.getElementById('canopy_info_div');
if(!infoDiv) { infoDiv = document.createElement('div'); }
infoDiv.id = 'canopy_info_div';
infoDiv.setAttribute('style','position: absolute; border: 1px solid black; bottom: 0px; right: 0px; margin: 3px; padding: 3px; background-color: white; z-index: 99999; font-size: 20px; font-family: monospace; font-weight: bold;');
document.getElementsByTagName('body')[0].appendChild(infoDiv);
infoDiv.innerHTML = 'locating: " + escapedText + "';"
swallowedJs info
if (showInfoDiv) then
let escapedText = System.Web.HttpUtility.JavaScriptStringEncode(text)
let info = "
var infoDiv = document.getElementById('canopy_info_div');
if(!infoDiv) { infoDiv = document.createElement('div'); }
infoDiv.id = 'canopy_info_div';
infoDiv.setAttribute('style','position: absolute; border: 1px solid black; bottom: 0px; right: 0px; margin: 3px; padding: 3px; background-color: white; z-index: 99999; font-size: 20px; font-family: monospace; font-weight: bold;');
document.getElementsByTagName('body')[0].appendChild(infoDiv);
infoDiv.innerHTML = 'locating: " + escapedText + "';"
swallowedJs info

let private wait timeout f =
let wait = new WebDriverWait(browser, TimeSpan.FromSeconds(timeout))
Expand Down
3 changes: 2 additions & 1 deletion src/canopy/configuration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ let mutable throwIfMoreThanOneElement = false
let mutable configuredFinders = finders.defaultFinders
let mutable writeToSelectWithOptionValue = true
let mutable optimizeBySkippingIFrameCheck = false
let mutable optimizeByDisablingCoverageReport = false
let mutable optimizeByDisablingCoverageReport = false
let mutable showInfoDiv = true

0 comments on commit 410f3f4

Please sign in to comment.