lefthandedgoat / canopy

f# web automation and testing library, built on top of Selenium (friendly to c# also)
http://lefthandedgoat.github.io/canopy/
MIT License
506 stars 115 forks source link

How do i use the canopy functions that return a Unit type for bool operations #437

Closed manishdube closed 6 years ago

manishdube commented 6 years ago

How do i use the canopy functions that return a Unit type for bool operations?

if (displayed "Eat better") then click ("#lbl-HealthyChangesImproveDiet-idx"+rnd.Next(0, 5).ToString())

for the above line the compiler throw an error saying...

" This expression was expected to have type 'bool'
but here has type 'unit' "

lefthandedgoat commented 6 years ago

You to write a new function that returns bool

let exists selector = 
  match someElement selector with
  | Some _ -> true
  | None -> false

if (exists "Eat better") then click ("#lbl-HealthyChangesImproveDiet-idx"+rnd.Next(0, 5).ToString())
manishdube commented 6 years ago

works wonderfully well. Thanks.