From f28a8b0a7339997f5d68abb96cfc604b60141d83 Mon Sep 17 00:00:00 2001 From: Rachel Reese Date: Fri, 4 Apr 2014 18:54:30 -0500 Subject: [PATCH 1/2] More idiomatically F#. :) --- canopy/canopy.fs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/canopy/canopy.fs b/canopy/canopy.fs index 35fcefb1..4c3db1d1 100644 --- a/canopy/canopy.fs +++ b/canopy/canopy.fs @@ -297,16 +297,15 @@ let ( << ) cssSelector text = try e.Clear() with ex -> ex |> ignore e.SendKeys(text) - let atleastOneItemWritten = ref false elements cssSelector - |> List.iter (fun elem -> - try - writeToElement elem - atleastOneItemWritten := true - with - | :? CanopyReadOnlyException as ex -> raise ex - | _ -> ()) - !atleastOneItemWritten) + |> List.exists (fun elem -> + try + writeToElement elem + true + with + | :? CanopyReadOnlyException as ex -> reraise() + | _ -> false) + ) let private textOf (element : IWebElement) = match element.TagName with From 74baeba42eecd2787105f9859af6f0826d4bef6d Mon Sep 17 00:00:00 2001 From: Rachel Reese Date: Sat, 5 Apr 2014 21:20:59 -0500 Subject: [PATCH 2/2] Moving List.exists to List.map. --- canopy/canopy.fs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/canopy/canopy.fs b/canopy/canopy.fs index 4c3db1d1..3edfd95c 100644 --- a/canopy/canopy.fs +++ b/canopy/canopy.fs @@ -298,13 +298,14 @@ let ( << ) cssSelector text = e.SendKeys(text) elements cssSelector - |> List.exists (fun elem -> + |> List.map (fun elem -> try writeToElement elem true with | :? CanopyReadOnlyException as ex -> reraise() | _ -> false) + |> List.exists (fun elem -> elem = true) ) let private textOf (element : IWebElement) =