diff --git a/src/canopy/canopy.fs b/src/canopy/canopy.fs index 3afed3e6..e4cbe4bc 100644 --- a/src/canopy/canopy.fs +++ b/src/canopy/canopy.fs @@ -1,6 +1,7 @@ [] module canopy.core +open System.Collections.ObjectModel open OpenQA.Selenium.Firefox open OpenQA.Selenium open OpenQA.Selenium.Interactions @@ -189,10 +190,12 @@ let private suggestOtherSelectors cssSelector = } } return texts;""" - let classes = js classesViaJs :?> System.Collections.ObjectModel.ReadOnlyCollection |> Seq.map (fun item -> "." + item.ToString()) |> Array.ofSeq - let ids = js idsViaJs :?> System.Collections.ObjectModel.ReadOnlyCollection |> Seq.map (fun item -> "#" + item.ToString()) |> Array.ofSeq - let values = js valuesViaJs :?> System.Collections.ObjectModel.ReadOnlyCollection |> Seq.map (fun item -> item.ToString()) |> Array.ofSeq - let texts = js textsViaJs :?> System.Collections.ObjectModel.ReadOnlyCollection |> 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 |> safeSeq |> Seq.map (fun item -> "." + safeToString item) |> Array.ofSeq + let ids = js idsViaJs :?> ReadOnlyCollection |> safeSeq |> Seq.map (fun item -> "#" + safeToString item) |> Array.ofSeq + let values = js valuesViaJs :?> ReadOnlyCollection |> safeSeq |> Seq.map (fun item -> safeToString item) |> Array.ofSeq + let texts = js textsViaJs :?> ReadOnlyCollection |> safeSeq |> Seq.map (fun item -> safeToString item) |> Array.ofSeq let results = Array.append classes ids