button extension in f# canopy

47 views Asked by At

I'm trying to make a general button extension in f# and canopy.

as you know we can click a button like this in canopy

click (//button[contains(text(),'save')])[last()]

But I'm trying to do something like this.

let _button value = sprintf "(//button[contains(text(),'%s')])[last()]" value
let button value = _button value 
click button "save"

but this gives This value is not a function and cannot be applied
Any great ideas?
Thanks in advance

1

There are 1 answers

0
Nghia Bui On BEST ANSWER

button is a function with signature: string -> string

click is a function with signature: string -> something

So, you cannot pass button to click, you should write:

click (button "save")

or

click <| button "save"

Idiomatically, I would rewrite your code as:

let button = sprintf "(//button[contains(text(),'%s')])[last()]"
click (button "save")

Related Questions in F#