简体   繁体   English

单击机盖WebElement

[英]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" “无法单击[OpenQA.Selenium.Remote.RemoteWebElement],因为它不是字符串或Web元素”

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. buttons.tail不是“最后一个按钮”,而是一个列表,其中包含所有按钮,但第一个按钮除外。 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: 要获取F#列表的最后一个元素,请使用List.last函数:

let buttons = elements ".buttonClass"
click (List.last buttons)

The list that's returned with elements (selector) is an IWebElement List elements (selector)一起返回的列表是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. 因此,通过使用buttons.Item (buttons.Length - 1)访问列表,我可以访问具有单击功能的WebElement对象。

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

Documentation for RemoteWebElement RemoteWebElement的文档

Canopy API Documentation 冠层API文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM