Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lefthandedgoat/canopy
Browse files Browse the repository at this point in the history
  • Loading branch information
lefthandedgoat committed Mar 29, 2014
2 parents 42a27d6 + 59815be commit 6d980ab
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 45 deletions.
4 changes: 2 additions & 2 deletions AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ open System.Reflection
[<assembly: AssemblyProductAttribute("canopy")>]
[<assembly: AssemblyTitleAttribute("canopy")>]
[<assembly: AssemblyDescriptionAttribute("A simple framework in f# on top of selenium for writing UI automation and tests. Change Log at https://github.com/lefthandedgoat/canopy/wiki/Change-Log")>]
[<assembly: AssemblyVersionAttribute("0.9.4")>]
[<assembly: AssemblyVersionAttribute("0.9.7")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "0.9.4"
let [<Literal>] Version = "0.9.7"
2 changes: 1 addition & 1 deletion Build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open Fake.AssemblyInfoFile

// Assembly / NuGet package properties
let projectName = "canopy"
let version = "0.9.4"
let version = "0.9.7"
let projectDescription = "A simple framework in f# on top of selenium for writing UI automation and tests. Change Log at https://github.com/lefthandedgoat/canopy/wiki/Change-Log"
let authors = ["Chris Holt"]

Expand Down
44 changes: 22 additions & 22 deletions basictests/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -533,24 +533,24 @@ context "User Agents tests"
url "http://whatsmyuseragent.com/"
"#body_lbUserAgent" =~ "iPad"

"FirefoxDeviceWithUserAgent userAgents.iPhone should show as iPhone" &&& fun _ ->
start <| FirefoxWithUserAgent userAgents.iPhone
url "http://whatsmyuseragent.com/"
"#body_lbUserAgent" =~ "iPhone"

"FirefoxDeviceWithUserAgent myagent should show as myagent" &&& fun _ ->
start <| FirefoxWithUserAgent "myagent"
url "http://whatsmyuseragent.com/"
"#body_lbUserAgent" == "myagent"
//"FirefoxDeviceWithUserAgent userAgents.iPhone should show as iPhone" &&& fun _ ->
// start <| FirefoxWithUserAgent userAgents.iPhone
// url "http://whatsmyuseragent.com/"
// "#body_lbUserAgent" =~ "iPhone"
//
//"FirefoxDeviceWithUserAgent myagent should show as myagent" &&& fun _ ->
// start <| FirefoxWithUserAgent "myagent"
// url "http://whatsmyuseragent.com/"
// "#body_lbUserAgent" == "myagent"

context "Resize tests"

"Firefox should be resized to 400,400" &&& fun _ ->
start firefox
url "http://resizemybrowser.com/"
resize (400,400)
"#cWidth" == "400"
"#cHeight" == "400"
//"Firefox should be resized to 400,400" &&& fun _ ->
// start firefox
// url "http://resizemybrowser.com/"
// resize (400,400)
// "#cWidth" == "400"
// "#cHeight" == "400"

"Chrome should be resized to iPhone4" &&& fun _ ->
start chrome
Expand All @@ -559,13 +559,13 @@ context "Resize tests"
"#cWidth" == "320"
"#cHeight" == "480"

"Firefox should be resized to 400,500 then rotated to 500,400" &&& fun _ ->
start firefox
url "http://resizemybrowser.com/"
resize (400,500)
rotate()
"#cHeight" == "400"
"#cWidth" == "500"
//"Firefox should be resized to 400,500 then rotated to 500,400" &&& fun _ ->
// start firefox
// url "http://resizemybrowser.com/"
// resize (400,500)
// rotate()
// "#cHeight" == "400"
// "#cWidth" == "500"

"Chrome should be resized and rotated to iPhone4" &&& fun _ ->
start chrome
Expand Down
4 changes: 4 additions & 0 deletions basictests/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<bindingRedirect oldVersion="2.3.5.0" newVersion="4.3.0.0" />
<bindingRedirect oldVersion="4.0.0.0" newVersion="4.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup>
Expand Down
6 changes: 3 additions & 3 deletions canopy.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<description>@description@</description>
<tags>f# fsharp canopy selenium ui automation tests</tags>
<dependencies>
<dependency id="Selenium.WebDriver" version="2.38.0" />
<dependency id="Selenium.Support" version="2.38.0" />
<dependency id="SizSelCsZzz" version="0.3.34.0" />
<dependency id="Selenium.WebDriver" version="[2.40.0]" />
<dependency id="Selenium.Support" version="[2.40.0]" />
<dependency id="SizSelCsZzz" version="[0.3.35.0]" />
</dependencies>
</metadata>
</package>
36 changes: 32 additions & 4 deletions canopy/canopy.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ open levenshtein
open reporters
open types
open finders
open System.Drawing
open System.Drawing.Imaging

let mutable (browser : IWebDriver) = null
let mutable (failureMessage : string) = null
Expand All @@ -31,13 +33,39 @@ let mutable browsers = []
//misc
let failsWith message = failureMessage <- message

let screenshot directory filename =
let pic = (browser :?> ITakesScreenshot).GetScreenshot().AsByteArray
let private saveScreenshot directory filename pic =
if not <| Directory.Exists(directory)
then Directory.CreateDirectory(directory) |> ignore
IO.File.WriteAllBytes(Path.Combine(directory,filename + ".png"), pic)
pic


let private takeScreenShotIfAlertUp () =
let bitmap = new Bitmap(width= System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, height= System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height, format=PixelFormat.Format32bppArgb);
use graphics = Graphics.FromImage(bitmap)
graphics.CopyFromScreen(System.Windows.Forms.Screen.PrimaryScreen.Bounds.X, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Y, 0, 0, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
use stream = new MemoryStream()
bitmap.Save(stream, ImageFormat.Png)
stream.Close()
stream.ToArray()


let private takeScreenshot directory filename =
try
let pic = (browser :?> ITakesScreenshot).GetScreenshot().AsByteArray
saveScreenshot directory filename pic
pic
with
| :? OpenQA.Selenium.UnhandledAlertException as ex->
let pic = takeScreenShotIfAlertUp()
saveScreenshot directory filename pic
let alert = browser.SwitchTo().Alert()
alert.Accept()
pic

let screenshot directory filename =
match box browser with
| :? ITakesScreenshot -> takeScreenshot directory filename
| _ -> Array.empty<byte>

let js script = (browser :?> IJavaScriptExecutor).ExecuteScript(script)

let private swallowedJs script = try js script |> ignore with | ex -> ()
Expand Down
8 changes: 4 additions & 4 deletions canopy/canopy.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@
</Reference>
<Reference Include="mscorlib" />
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\net40\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.6.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SizSelCsZzz">
<HintPath>..\packages\SizSelCsZzz.0.3.34.0\lib\SizSelCsZzz.dll</HintPath>
<HintPath>..\packages\SizSelCsZzz.0.3.35.0\lib\SizSelCsZzz.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand All @@ -87,11 +87,11 @@
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="WebDriver">
<HintPath>..\packages\Selenium.WebDriver.2.38.0\lib\net40\WebDriver.dll</HintPath>
<HintPath>..\packages\Selenium.WebDriver.2.40.0\lib\net40\WebDriver.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WebDriver.Support">
<HintPath>..\packages\Selenium.Support.2.38.0\lib\net40\WebDriver.Support.dll</HintPath>
<HintPath>..\packages\Selenium.Support.2.40.0\lib\net40\WebDriver.Support.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions canopy/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net40" />
<package id="Selenium.Support" version="2.38.0" targetFramework="net40" />
<package id="Selenium.WebDriver" version="2.38.0" targetFramework="net40" />
<package id="SizSelCsZzz" version="0.3.34.0" targetFramework="net40" />
<package id="Newtonsoft.Json" version="6.0.1" targetFramework="net40" />
<package id="Selenium.Support" version="2.40.0" targetFramework="net40" />
<package id="Selenium.WebDriver" version="2.40.0" targetFramework="net40" />
<package id="SizSelCsZzz" version="0.3.35.0" targetFramework="net40" />
</packages>
4 changes: 4 additions & 0 deletions documentationtests/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
<assemblyIdentity name="WebDriver.Support" publicKeyToken="1c2bd1631853048f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.32.0.0" newVersion="2.32.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
14 changes: 9 additions & 5 deletions sampleprojectstructure/App.config
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="4.0.0.0" newVersion="4.3.0.0"/>
<bindingRedirect oldVersion="2.3.5.0" newVersion="4.3.0.0"/>
<bindingRedirect oldVersion="2.0.0.0" newVersion="4.3.0.0"/>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="4.0.0.0" newVersion="4.3.0.0" />
<bindingRedirect oldVersion="2.3.5.0" newVersion="4.3.0.0" />
<bindingRedirect oldVersion="2.0.0.0" newVersion="4.3.0.0" />

</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

0 comments on commit 6d980ab

Please sign in to comment.