From 9100c7da51d9d2f1caf69a06fec0c53108c95bff Mon Sep 17 00:00:00 2001 From: Kevin Miller Date: Fri, 6 Sep 2013 10:03:09 -0500 Subject: [PATCH] Support sleeping for fractions of seconds. * sleep 1.5 * sleep 0.5 * sleep 1 * sleep --- basictests/Program.fs | 2 +- canopy/canopy.fs | 8 +++++--- canopy/configuration.fs | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/basictests/Program.fs b/basictests/Program.fs index 11de07fe..44d5ddd3 100644 --- a/basictests/Program.fs +++ b/basictests/Program.fs @@ -291,7 +291,7 @@ before (fun _ -> Console.WriteLine "only before set now") "ajax button should click after sleep" &&& (fun _ -> !^ testpage "#ajax_button_clicked" == "ajax button not clicked" - sleep 3 + sleep 2.5 click "#ajax_button" "#ajax_button_clicked" == "ajax button clicked") diff --git a/canopy/canopy.fs b/canopy/canopy.fs index a61b000f..1e99bf30 100644 --- a/canopy/canopy.fs +++ b/canopy/canopy.fs @@ -79,9 +79,11 @@ let js script = (browser :?> IJavaScriptExecutor).ExecuteScript(script) let private swallowedJs script = try js script |> ignore with | ex -> () let sleep seconds = - match box seconds with - | :? int as i -> System.Threading.Thread.Sleep(i * 1000) - | _ -> System.Threading.Thread.Sleep(1 * 1000) + let ms = match box seconds with + | :? int as i -> i * 1000 + | :? float as i -> Convert.ToInt32(i * 1000.0) + | _ -> 1000 + System.Threading.Thread.Sleep(ms) let puts (text : string) = reporter.write text diff --git a/canopy/configuration.fs b/canopy/configuration.fs index 496b2112..6bd5930c 100644 --- a/canopy/configuration.fs +++ b/canopy/configuration.fs @@ -10,7 +10,7 @@ let mutable phantomJSDir = @"c:\" let mutable elementTimeout = 10.0 let mutable compareTimeout = 10.0 let mutable pageTimeout = 10.0 -let mutable wipSleep = 1 +let mutable wipSleep = 1.0 let mutable runFailedContextsFirst = false let mutable reporter : IReporter = new ConsoleReporter() :> IReporter let mutable disableSuggestOtherSelectors = false