Skip to content

Commit

Permalink
Hopefully a fix for #404, null ref while giving suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
lefthandedgoat committed Mar 3, 2018
1 parent 283dd19 commit 77fc454
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/canopy/canopy.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[<AutoOpen>]
module canopy.core

open System.Collections.ObjectModel
open OpenQA.Selenium.Firefox
open OpenQA.Selenium
open OpenQA.Selenium.Interactions
Expand Down Expand Up @@ -189,10 +190,12 @@ let private suggestOtherSelectors cssSelector =
}
}
return texts;"""
let classes = js classesViaJs :?> System.Collections.ObjectModel.ReadOnlyCollection<System.Object> |> Seq.map (fun item -> "." + item.ToString()) |> Array.ofSeq
let ids = js idsViaJs :?> System.Collections.ObjectModel.ReadOnlyCollection<System.Object> |> Seq.map (fun item -> "#" + item.ToString()) |> Array.ofSeq
let values = js valuesViaJs :?> System.Collections.ObjectModel.ReadOnlyCollection<System.Object> |> Seq.map (fun item -> item.ToString()) |> Array.ofSeq
let texts = js textsViaJs :?> System.Collections.ObjectModel.ReadOnlyCollection<System.Object> |> Seq.map (fun item -> item.ToString()) |> Array.ofSeq
let safeSeq orig = if orig = null then Seq.empty else orig
let safeToString orig = if orig = null then "" else orig.ToString()
let classes = js classesViaJs :?> ReadOnlyCollection<System.Object> |> safeSeq |> Seq.map (fun item -> "." + safeToString item) |> Array.ofSeq
let ids = js idsViaJs :?> ReadOnlyCollection<System.Object> |> safeSeq |> Seq.map (fun item -> "#" + safeToString item) |> Array.ofSeq
let values = js valuesViaJs :?> ReadOnlyCollection<System.Object> |> safeSeq |> Seq.map (fun item -> safeToString item) |> Array.ofSeq
let texts = js textsViaJs :?> ReadOnlyCollection<System.Object> |> safeSeq |> Seq.map (fun item -> safeToString item) |> Array.ofSeq

let results =
Array.append classes ids
Expand Down

0 comments on commit 77fc454

Please sign in to comment.