Assertions

== (equals)

Assert that the element on the left is equal to the value on the right.

1: 
"#firstName" == "Alex"

!= (does not equal)

Assert that the element on the left is not equal to the value on the right.

1: 
"#firstName" != "Tom"

=== (aliased as is)

Assert that the value on the left is equal to the value on right. * Note: does not use retry-ability. Equivalent to Assert.Equals.

1: 
"Not a selector" === "Not a selector"

*= (one of many equals)

Assert that at least one element in a list equals a value.

1: 
".todoItem" *= "Buy milk"

*!= (none equals)

Assert that none of the items in a list equals a value.

1: 
".todoItem" *!= "Sell everything"

contains

Assert that one string contains another.

1: 
contains "Log" (read "#logout")

containsInsensitive

Assert that one string contains (case insensitive) another.

1: 
containsInsensitive "Log" (read "#logout")

notContains

Assert that one string does not contains another.

1: 
notContains "Hello Bob!" (read "#name")

count

Assert there are X items of given css selector.

1: 
count ".todoItem" 5

=~ (regex match)

Assert that an element regex matches a value.

1: 
2: 
3: 
4: 
"#lastName" << "Gray"
"#lastName" =~ "Gr[ae]y"
"#lastName" << "Grey"
"#lastName" =~ "Gr[ae]y"

!=~ (regex match)

Assert that an element does not regex match a value.

1: 
2: 
3: 
4: 
"#lastName" << "Gr0y"
"#lastName" !=~ "Gr[ae]y"
"#lastName" << "Gr1y"
"#lastName" !=~ "Gr[ae]y"

*~ (one of many regex match)

Assert that one of many element regex matches a value.

1: 
"#colors li" *~ "gr[ea]y"

on

Assert that the browser is currently on a url. Falls back to using String.Contains after page timeout.

1: 
2: 
url "https://duckduckgo.com/?q=canopy+f%23"
on "https://duckduckgo.com/?q"

onn

Same as on but does not fall back to using String.Contains.

1: 
2: 
url "https://duckduckgo.com/about"
onn "https://duckduckgo.com/about"

selected

Assert that a radio or checkbox is selected.

1: 
selected "#yes"

deselected

Assert that a radio or checkbox is not selected.

1: 
deselected "#yes"

displayed

Assert that an element is displayed on the screen. (Note: Will not walk up the dom. If a parent container is hidden this may give the wrong results, try adding :visible to selector)

1: 
displayed "#modal"

notDisplayed

Assert that an element is not displayed on the screen. (Note: Will not walk up the dom. If a parent container is hidden this may give the wrong results, try adding :visible to selector)

1: 
notDisplayed "#modal"

enabled

Assert that an element is enabled.

1: 
enabled "#button"

disabled

Assert that an element is not enabled.

1: 
disabled "#button"

fadedIn

Returns true/false if element has finished fading in and is shown.

1: 
2: 
let isShown = (fadedIn "#message")()
waitFor <| fadedIn "#message"
namespace canopy
module classic

from canopy
namespace canopy.runner
namespace System
val contains : value1:string -> value2:string -> unit
val read : item:'a -> string
val containsInsensitive : value1:string -> value2:string -> unit
val notContains : value1:string -> value2:string -> unit
val count : cssSelector:string -> count':int -> unit
val url : u:string -> unit
val on : u:string -> unit
val onn : u:string -> unit
val selected : item:'a -> unit
val deselected : item:'a -> unit
val displayed : item:'a -> unit
val notDisplayed : item:'a -> unit
val enabled : item:'a -> unit
val disabled : item:'a -> unit
val isShown : bool
val fadedIn : cssSelector:string -> ('a -> bool)
val waitFor : ((unit -> bool) -> unit)