Search code examples
f#canopy-web-testing

Click a Canopy WebElement


I have a button that I am retrieving with canopy like this...

let buttons = elements ".buttonClass"

The last button is the one I want to click, but when I do...

click buttons.tail

I get an error that says

"Can't click [OpenQA.Selenium.Remote.RemoteWebElement] because it is not a string or webelement"

So my question is, is there a way to do what I'm trying to do?


Solution

  • The list that's returned with elements (selector) is an IWebElement List

    So, by accessing the list with buttons.Item (buttons.Length - 1) I am able to access the WebElement object which has a click function on it.

    let buttons = elements ".buttonClass"
    (buttons.Item (buttons.Length - 1)).Click()
    

    Documentation for RemoteWebElement

    Canopy API Documentation