0

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?

4

2 回答 2

4

buttons.tail不是“最后一个按钮”,而是由除第一个按钮之外的所有按钮组成的列表。这就是“尾巴”通常与列表相关的含义。尝试这个:

let list = [1;2;3]
let tail = list.Tail   // tail = [2;3]

要获取 F# 列表的最后一个元素,请使用以下List.last函数:

let buttons = elements ".buttonClass"
click (List.last buttons)
于 2017-02-24T04:11:25.773 回答
0

返回的列表elements (selector)IWebElement List

因此,通过访问列表,buttons.Item (buttons.Length - 1)我可以访问WebElement具有点击功能的对象。

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

RemoteWebElement 文档

冠层 API 文档

于 2017-02-24T04:14:00.863 回答