From 1b9666c9dff636360d2168839cc6ab9997bbd5aa Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Mon, 20 Feb 2017 20:07:13 +0100 Subject: [PATCH] Better error when browser is null in url function (#348) --- src/canopy/canopy.fs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/canopy/canopy.fs b/src/canopy/canopy.fs index 4ef6b7c3..6290a512 100644 --- a/src/canopy/canopy.fs +++ b/src/canopy/canopy.fs @@ -941,7 +941,10 @@ let on (u: string) = | ex -> if browser.Url.Contains(u) = false then raise (CanopyOnException(sprintf "on check failed, expected expression '%s' got %s" u browser.Url)) (* documented/actions *) -let ( !^ ) (u : string) = browser.Navigate().GoToUrl(u) +let ( !^ ) (u : string) = + if browser == null then + raise (CanopyOnException "Can't navigate to the given url since the browser is not initialized.") + browser.Navigate().GoToUrl(u) (* documented/actions *) let url u = !^ u @@ -1039,4 +1042,4 @@ let skip message = (* documented/actions *) let waitForElement cssSelector = - waitFor (fun _ -> someElement cssSelector |> Option.isSome) \ No newline at end of file + waitFor (fun _ -> someElement cssSelector |> Option.isSome)