简体   繁体   English

Selenium webdriverJS selectByIndex()方法

[英]Selenium webdriverJS selectByIndex() Method

I am trying to find out the JavaScript equivalent of the selectByIndex() method that is provided in the Java Webdriver API. 我正在尝试找出Java Webdriver API中提供的selectByIndex()方法的JavaScript等效项。 I am trying to do what is addressed in this question (but using the WebdriverJS framework): 我正在尝试做这个问题要解决的问题 (但是使用WebdriverJS框架):

I have looked at the WebdriverJS source , but haven't found anything. 我看过WebdriverJS源码 ,但是什么也没找到。

Is there a way to select an element based off of its index position using Selenium's Javascript Webdriver? 有没有一种方法可以使用Selenium的Javascript Webdriver根据索引位置选择元素?

Could you do something like this? 你能做这样的事情吗?

var index = {your in index}
driver.findElements(By.css('option'))
    .then(function(options){
        return options[index].click();
    });

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

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