Search code examples
f#canopycanopy-web-testing

button extension in f# canopy


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


Solution

  • 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")