Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to latest selenium, fixes #205, adds better reporting #207

Merged
merged 1 commit into from
Jul 31, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,10 @@
* Fix broken link to html reporter introduced in 0.9.27

#### 0.9.29 - June 17 2015
* Fix issue 203, using canopy for unit tests [Issue #203](https://github.com/lefthandedgoat/canopy/issues/203)
* Fix issue 203, using canopy for unit tests [Issue #203](https://github.com/lefthandedgoat/canopy/issues/203)

#### 0.9.30 - July 30 2015
* Updated to Selenium 2.47
* Fix issue 205, making switchToTab more reliable [Issue #205](https://github.com/lefthandedgoat/canopy/issues/205)
* Improve LiveHtmlReporter so that puts and describe will add ordered messages to the output
* Improved behaviour for failing all tests if on failed. Changed it to only fail all tests if the 'once' function fails
26 changes: 20 additions & 6 deletions docs/files/reporttemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,32 @@
$("#todo").text($(".results .warning").length);
$("#skipped").text($(".results .info").length);
};

var addToContext = function (context, passFailSkip, testName, image) {

var addToContext = function (context, testName) {
var ctx = $('#contexts tr[data-context="' + context + '"]');
ctx.next('tr').find('table').append('<tr><td><div class="test">' + testName + '</div></td></tr>');
};

var updateTestInContext = function (context, passFailSkip, image) {
var ctx = $('#contexts tr[data-context="' + context + '"]');
if (passFailSkip === "Pass") {
ctx.next('tr').find('table').last('tr').append('<tr class="success"><td><div class="test">' + testName + '</div></td></tr>');
ctx.next('tr').find('table').find('tr').last().addClass('success');
if (ctx.hasClass("error") === false) {
ctx.removeClass("warning").removeClass("info").addClass("success");
}
}
if (passFailSkip === "Fail") {
ctx.next('tr').find('table').last('tr').append('<tr class="error"><td><div class="test">' + testName + '</div></td></tr>');
ctx.next('tr').find('table').find('tr').last().addClass('error');
ctx.removeClass("success").removeClass("warning").removeClass("info").addClass("error");
}
if (passFailSkip === "Todo") {
ctx.next('tr').find('table').last('tr').append('<tr class="warning"><td><div class="test">' + testName + '</div></td></tr>');
ctx.next('tr').find('table').find('tr').last().addClass('warning');
if (ctx.hasClass("error") === false && ctx.hasClass("info") === false && ctx.hasClass("success") === false){
ctx.addClass("warning");
}
}
if (passFailSkip === "Skip") {
ctx.next('tr').find('table').last('tr').append('<tr class="info"><td><div class="test">' + testName + '</div></td></tr>');
ctx.next('tr').find('table').find('tr').last().addClass('info');
if (ctx.hasClass("error") === false && ctx.hasClass("warning") === false && ctx.hasClass("success") === false){
ctx.addClass("info");
}
Expand All @@ -130,6 +135,15 @@
ctx.next('tr').find('table').last('tr').find('.test').last().after('<div class="stack"><pre>' + stack + '</pre></div>');
};

var addMessageToTest = function (context, message) {
var ctx = $('#contexts tr[data-context="' + context + '"]');
if(ctx.next('tr').find('table').last('tr').find('.test').last().siblings('pre').length === 0) {
ctx.next('tr').find('table').last('tr').find('.test').last().after('<pre><ol class="message"><li>' + message + '</li></ol></pre>');
} else {
ctx.next('tr').find('table').last('tr').find('.test').last().siblings('pre').find('ol').append('<li>' + message + '</li>');
}
};

var collapseContextsExcept = function (context) {
var ctxs = $('#contexts tr.result[data-owning-context !="' + context + '"]');
ctxs.each(function () {
Expand Down
4 changes: 2 additions & 2 deletions nuget/canopy.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<tags>@tags@</tags>
<dependencies>
<dependency id="FSharp.Core" version="3.0.2" />
<dependency id="Selenium.WebDriver" version="[2.46.0]" />
<dependency id="Selenium.Support" version="[2.46.0]" />
<dependency id="Selenium.WebDriver" version="[2.47.0]" />
<dependency id="Selenium.Support" version="[2.47.0]" />
<dependency id="SizSelCsZzz" version="[0.3.36.0]" />
</dependencies>
</metadata>
Expand Down
6 changes: 3 additions & 3 deletions src/canopy/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ open System.Reflection
[<assembly: AssemblyTitleAttribute("canopy")>]
[<assembly: AssemblyProductAttribute("canopy")>]
[<assembly: AssemblyDescriptionAttribute("F# web testing framework")>]
[<assembly: AssemblyVersionAttribute("0.9.29")>]
[<assembly: AssemblyFileVersionAttribute("0.9.29")>]
[<assembly: AssemblyVersionAttribute("0.9.30")>]
[<assembly: AssemblyFileVersionAttribute("0.9.30")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "0.9.29"
let [<Literal>] Version = "0.9.30"
10 changes: 8 additions & 2 deletions src/canopy/canopy.fs
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,14 @@ let start b =
let switchTo b = browser <- b

let switchToTab number =
let tabs = browser.WindowHandles;
browser.SwitchTo().Window(tabs.[(number - 1)]) |> ignore
wait pageTimeout (fun _ ->
let number = number - 1
let tabs = browser.WindowHandles;
if tabs |> Seq.length >= number then
browser.SwitchTo().Window(tabs.[number]) |> ignore
true
else
false)

let closeTab number =
switchToTab number
Expand Down
4 changes: 2 additions & 2 deletions src/canopy/canopy.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="WebDriver">
<HintPath>..\..\packages\Selenium.WebDriver.2.46.0\lib\net40\WebDriver.dll</HintPath>
<HintPath>..\..\packages\Selenium.WebDriver.2.47.0\lib\net40\WebDriver.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WebDriver.Support">
<HintPath>..\..\packages\Selenium.Support.2.46.0\lib\net40\WebDriver.Support.dll</HintPath>
<HintPath>..\..\packages\Selenium.Support.2.47.0\lib\net40\WebDriver.Support.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/canopy/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<packages>
<package id="FSharp.Core" version="3.0.2" targetFramework="net40" />
<package id="Newtonsoft.Json" version="6.0.6" targetFramework="net40" />
<package id="Selenium.Support" version="2.46.0" targetFramework="net40" />
<package id="Selenium.WebDriver" version="2.46.0" targetFramework="net40" />
<package id="Selenium.Support" version="2.47.0" targetFramework="net40" />
<package id="Selenium.WebDriver" version="2.47.0" targetFramework="net40" />
<package id="SizSelCsZzz" version="0.3.36.0" targetFramework="net40" />
</packages>
16 changes: 10 additions & 6 deletions src/canopy/reporters.fs
Original file line number Diff line number Diff line change
Expand Up @@ -221,18 +221,19 @@ type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string) =

interface IReporter with
member this.pass () =
this.swallowedJS (sprintf "addToContext('%s', 'Pass', '%s', '%s');" context test "")
this.swallowedJS (sprintf "updateTestInContext('%s', 'Pass', '%s');" context "")
consoleReporter.pass ()

member this.fail ex id ss url =
this.swallowedJS (sprintf "addToContext('%s', 'Fail', '%s', '%s');" context test (Convert.ToBase64String(ss)))
this.swallowedJS (sprintf "updateTestInContext('%s', 'Fail', '%s');" context (Convert.ToBase64String(ss)))
let stack = sprintf "%s%s%s" ex.Message System.Environment.NewLine ex.StackTrace
let stack = System.Web.HttpUtility.JavaScriptStringEncode(stack)
this.swallowedJS (sprintf "addStackToTest ('%s', '%s');" context stack)
this.swallowedJS (sprintf "addUrlToTest ('%s', '%s');" context url)
consoleReporter.fail ex id ss url

member this.describe d =
member this.describe d =
this.swallowedJS (sprintf "addMessageToTest ('%s', '%s');" context d)
consoleReporter.describe d

member this.contextStart c =
Expand All @@ -249,13 +250,15 @@ type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string) =
consoleReporter.summary minutes seconds passed failed

member this.write w =
this.swallowedJS (sprintf "addMessageToTest ('%s', '%s');" context w)
consoleReporter.write w

member this.suggestSelectors selector suggestions =
consoleReporter.suggestSelectors selector suggestions

member this.testStart id =
test <- System.Web.HttpUtility.JavaScriptStringEncode(id)
this.swallowedJS (sprintf "addToContext ('%s', '%s');" context test)
consoleReporter.testStart id

member this.testEnd id = ()
Expand All @@ -279,10 +282,11 @@ type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string) =
if (contexts |> List.exists (fun c -> c = "Coverage Reports")) = false then
contexts <- "Coverage Reports" :: contexts
this.swallowedJS (sprintf "addContext('%s');" "Coverage Reports")
this.swallowedJS (sprintf "addToContext('%s', 'Pass', '%s', '%s');" "Coverage Reports" url (Convert.ToBase64String(ss)))
this.swallowedJS (sprintf "addToContext ('%s', '%s');" "Coverage Reports" url)
this.swallowedJS (sprintf "updateTestInContext('%s', 'Pass', '%s');" "Coverage Reports" (Convert.ToBase64String(ss)))

member this.todo () =
this.swallowedJS (sprintf "addToContext('%s', 'Todo', '%s', '%s');" context test "")
this.swallowedJS (sprintf "updateTestInContext('%s', 'Todo', '%s');" context "")

member this.skip () =
this.swallowedJS (sprintf "addToContext('%s', 'Skip', '%s', '%s');" context test "")
this.swallowedJS (sprintf "updateTestInContext('%s', 'Skip', '%s');" context "")
4 changes: 2 additions & 2 deletions tests/basictests/basictests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Numerics" />
<Reference Include="WebDriver">
<HintPath>..\..\packages\Selenium.WebDriver.2.46.0\lib\net40\WebDriver.dll</HintPath>
<HintPath>..\..\packages\Selenium.WebDriver.2.47.0\lib\net40\WebDriver.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WebDriver.Support">
<HintPath>..\..\packages\Selenium.Support.2.46.0\lib\net40\WebDriver.Support.dll</HintPath>
<HintPath>..\..\packages\Selenium.Support.2.47.0\lib\net40\WebDriver.Support.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions tests/basictests/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<packages>
<package id="FSharp.Core" version="3.0.2" targetFramework="net40" />
<package id="Newtonsoft.Json" version="6.0.6" targetFramework="net40" />
<package id="Selenium.Support" version="2.46.0" targetFramework="net40" />
<package id="Selenium.WebDriver" version="2.46.0" targetFramework="net40" />
<package id="Selenium.Support" version="2.47.0" targetFramework="net40" />
<package id="Selenium.WebDriver" version="2.47.0" targetFramework="net40" />
</packages>