Skip to content

Commit

Permalink
Changes for #202, update html reporter, update to selenium 2.46
Browse files Browse the repository at this point in the history
  • Loading branch information
lefthandedgoat committed Jun 16, 2015
1 parent 7c41dc1 commit a5cf7b1
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 43 deletions.
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,7 @@

#### 0.9.26 - June 1 2015
* Fixed bug where after wouldn't run following a failed test [Issue #197](https://github.com/lefthandedgoat/canopy/issues/197)

#### 0.9.27 - June 15 2015
* Improved Html reporter to have stack trace, error message and url of failing page [Issue #202](https://github.com/lefthandedgoat/canopy/issues/202)
* Updated to Selenium 2.46
31 changes: 20 additions & 11 deletions docs/files/reporttemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,50 +91,59 @@
var addToContext = function (context, passFailSkip, testName, image) {
var ctx = $('#contexts tr[data-context="' + context + '"]');
if (passFailSkip === "Pass") {
ctx.next('tr').find('table').last('tr').append('<tr class="success"><td>' + testName + '</td></tr>');
ctx.next('tr').find('table').last('tr').append('<tr class="success"><td><div class="test">' + testName + '</div></td></tr>');
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>' + testName + '</td></tr>');
ctx.next('tr').find('table').last('tr').append('<tr class="error"><td><div class="test">' + testName + '</div></td></tr>');
ctx.removeClass("success").removeClass("warning").removeClass("info").addClass("error");
}
if (passFailSkip === "Todo") {
ctx.next('tr').find('table').last('tr').append('<tr class="warning"><td>' + testName + '</td></tr>');
ctx.next('tr').find('table').last('tr').append('<tr class="warning"><td><div class="test">' + testName + '</div></td></tr>');
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>' + testName + '</td></tr>');
ctx.next('tr').find('table').last('tr').append('<tr class="info"><td><div class="test">' + testName + '</div></td></tr>');
if (ctx.hasClass("error") === false && ctx.hasClass("warning") === false && ctx.hasClass("success") === false){
ctx.addClass("info");
}
}

if(image !== "") {
ctx.next('tr').find('table').find('tr').last().find('td').last().append('<td><img alt="" src="data:image/jpeg;base64,' + image + '" /></td>')
ctx.next('tr').find('table').find('tr').last().find('td').last().append('<div><img alt="" src="data:image/jpeg;base64,' + image + '" /></div>')
}

recalculateTotals();
};

var addUrlToTest = function (context, url) {
var ctx = $('#contexts tr[data-context="' + context + '"]');
ctx.next('tr').find('table').last('tr').find('.test').last().after('<div class="url"><pre>' + url + '</pre></div>');
};

var addStackToTest = function (context, stack) {
var ctx = $('#contexts tr[data-context="' + context + '"]');
ctx.next('tr').find('table').last('tr').find('.test').last().after('<div class="stack"><pre>' + stack + '</pre></div>');
};

var collapseContextsExcept = function (context) {
var ctxs = $('#contexts tr.result[data-owning-context !="' + context + '"]');
ctxs.each(function () {
$(this).hide();
});
};

$(document).ready(function() {

$(document).ready(function() {
var showHide = function(next) {
if (next.is(":visible")) {
next.hide();
} else {
next.show();
}
next.hide();
} else {
next.show();
}
};

//wire up to existing contexts on the page
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.45.0]" />
<dependency id="Selenium.Support" version="[2.45.0]" />
<dependency id="Selenium.WebDriver" version="[2.46.0]" />
<dependency id="Selenium.Support" version="[2.46.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.26")>]
[<assembly: AssemblyFileVersionAttribute("0.9.26")>]
[<assembly: AssemblyVersionAttribute("0.9.27")>]
[<assembly: AssemblyFileVersionAttribute("0.9.27")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "0.9.26"
let [<Literal>] Version = "0.9.27"
7 changes: 2 additions & 5 deletions src/canopy/canopy.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@
<HintPath>..\..\packages\FSharp.Core.3.0.2\lib\net40\FSharp.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>False</Private>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\packages\Newtonsoft.Json.6.0.6\lib\net40\Newtonsoft.Json.dll</HintPath>
Expand All @@ -87,11 +84,11 @@
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="WebDriver">
<HintPath>..\..\packages\Selenium.WebDriver.2.45.0\lib\net40\WebDriver.dll</HintPath>
<HintPath>..\..\packages\Selenium.WebDriver.2.46.0\lib\net40\WebDriver.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WebDriver.Support">
<HintPath>..\..\packages\Selenium.Support.2.45.0\lib\net40\WebDriver.Support.dll</HintPath>
<HintPath>..\..\packages\Selenium.Support.2.46.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.45.0" targetFramework="net40" />
<package id="Selenium.WebDriver" version="2.45.0" targetFramework="net40" />
<package id="Selenium.Support" version="2.46.0" targetFramework="net40" />
<package id="Selenium.WebDriver" version="2.46.0" targetFramework="net40" />
<package id="SizSelCsZzz" version="0.3.36.0" targetFramework="net40" />
</packages>
20 changes: 13 additions & 7 deletions src/canopy/reporters.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ open types
type IReporter =
abstract member testStart : string -> unit
abstract member pass : unit -> unit
abstract member fail : Exception -> string -> byte [] -> unit
abstract member fail : Exception -> string -> byte [] -> string -> unit
abstract member todo : unit -> unit
abstract member skip : unit -> unit
abstract member testEnd : string -> unit
Expand All @@ -29,11 +29,13 @@ type ConsoleReporter() =
Console.WriteLine("Passed");
Console.ResetColor()

member this.fail ex id ss =
member this.fail ex id ss url =
Console.ForegroundColor <- ConsoleColor.Red
Console.WriteLine("Error: ");
Console.ResetColor()
Console.WriteLine(ex.Message);
Console.Write("Url: ");
Console.WriteLine(url);
Console.WriteLine("Stack: ");
ex.StackTrace.Split([| "\r\n"; "\n" |], StringSplitOptions.None)
|> Array.iter (fun trace ->
Expand Down Expand Up @@ -119,7 +121,7 @@ type TeamCityReporter() =
interface IReporter with
member this.pass () = consoleReporter.pass ()
member this.fail ex id ss =
member this.fail ex id ss url =
let mutable image = ""
if not (Array.isEmpty ss) then
image <- String.Format("canopy-image({0})", Convert.ToBase64String(ss))
Expand All @@ -128,7 +130,7 @@ type TeamCityReporter() =
(tcFriendlyMessage id)
(tcFriendlyMessage ex.Message)
(tcFriendlyMessage image))
consoleReporter.fail ex id ss
consoleReporter.fail ex id ss url
member this.describe d =
teamcityReport (sprintf "message text='%s' status='NORMAL'" (tcFriendlyMessage d))
Expand Down Expand Up @@ -207,7 +209,7 @@ type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string) =
with get () = _browser
member val reportPath = None with get, set
member val reportTemplateUrl = @"http://lefthandedgoat.github.com/canopy/reporttemplate.html" with get, set
member val reportTemplateUrl = @"file:///C:/projects/canopy/docs/files/reporttemplate.html" with get, set
member this.js script = (_browser :?> IJavaScriptExecutor).ExecuteScript(script)
member this.reportHtml () = (this.js "return $('*').html();").ToString()
member private this.swallowedJS script = try (_browser :?> IJavaScriptExecutor).ExecuteScript(script) |> ignore with | ex -> ()
Expand All @@ -222,9 +224,13 @@ type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string) =
this.swallowedJS (sprintf "addToContext('%s', 'Pass', '%s', '%s');" context test "")
consoleReporter.pass ()

member this.fail ex id ss =
member this.fail ex id ss url =
this.swallowedJS (sprintf "addToContext('%s', 'Fail', '%s', '%s');" context test (Convert.ToBase64String(ss)))
consoleReporter.fail ex id 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 =
consoleReporter.describe d
Expand Down
4 changes: 2 additions & 2 deletions src/canopy/runner.fs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ let fail (ex : Exception) id =
let failSuite (ex: Exception) (suite : suite) =
let reportFailedTest (ex: Exception) (test : Test) =
reporter.testStart test.Id
fail ex test.Id
fail ex test.Id browser.Url
reporter.testEnd test.Id
suite.Tests |> List.iter (fun test -> reportFailedTest ex test)

Expand All @@ -104,7 +104,7 @@ let run () =
pass()
with
| ex when failureMessage <> null && failureMessage = ex.Message -> pass()
| ex -> fail ex test.Id
| ex -> fail ex test.Id browser.Url
reporter.testEnd test.Id

failureMessage <- null
Expand Down
4 changes: 2 additions & 2 deletions src/sampleprojectstructure/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FSharp.Core" version="3.0.2" targetFramework="net45" />
<package id="Selenium.Support" version="2.45.0" targetFramework="net45" />
<package id="Selenium.WebDriver" version="2.45.0" targetFramework="net45" />
<package id="Selenium.Support" version="2.46.0" targetFramework="net45" />
<package id="Selenium.WebDriver" version="2.46.0" targetFramework="net45" />
</packages>
6 changes: 5 additions & 1 deletion src/sampleprojectstructure/sampleprojectstructure.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Numerics" />
<Reference Include="WebDriver">
<HintPath>..\..\packages\Selenium.WebDriver.2.45.0\lib\net40\WebDriver.dll</HintPath>
<HintPath>..\..\packages\Selenium.WebDriver.2.46.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>
<Private>True</Private>
</Reference>
</ItemGroup>
Expand Down
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.45.0\lib\net40\WebDriver.dll</HintPath>
<HintPath>..\..\packages\Selenium.WebDriver.2.46.0\lib\net40\WebDriver.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WebDriver.Support">
<HintPath>..\..\packages\Selenium.Support.2.45.0\lib\net40\WebDriver.Support.dll</HintPath>
<HintPath>..\..\packages\Selenium.Support.2.46.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.45.0" targetFramework="net40" />
<package id="Selenium.WebDriver" version="2.45.0" targetFramework="net40" />
<package id="Selenium.Support" version="2.46.0" targetFramework="net40" />
<package id="Selenium.WebDriver" version="2.46.0" targetFramework="net40" />
</packages>
4 changes: 2 additions & 2 deletions tests/documentationtests/documentationtests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Numerics" />
<Reference Include="WebDriver">
<HintPath>..\..\packages\Selenium.WebDriver.2.44.0\lib\net40\WebDriver.dll</HintPath>
<HintPath>..\..\packages\Selenium.WebDriver.2.46.0\lib\net40\WebDriver.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WebDriver.Support">
<HintPath>..\..\packages\Selenium.Support.2.44.0\lib\net40\WebDriver.Support.dll</HintPath>
<HintPath>..\..\packages\Selenium.Support.2.46.0\lib\net40\WebDriver.Support.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions tests/documentationtests/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FSharp.Core" version="3.0.2" targetFramework="net40" />
<package id="Selenium.Support" version="2.44.0" targetFramework="net40" />
<package id="Selenium.WebDriver" version="2.44.0" targetFramework="net40" />
<package id="Selenium.Support" version="2.46.0" targetFramework="net40" />
<package id="Selenium.WebDriver" version="2.46.0" targetFramework="net40" />
</packages>

0 comments on commit a5cf7b1

Please sign in to comment.