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?
buttons.tail
is not the "last button", but a list consisting of all buttons but the first one. That's what "tail" normally means in relation to lists. Try this:
let list = [1;2;3]
let tail = list.Tail // tail = [2;3]
To get the last element of an F# list, use the List.last
function:
let buttons = elements ".buttonClass"
click (List.last buttons)
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()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.