选择WebDriverJs中的下拉列表 [英] Selecting dropdown in WebDriverJs
本文介绍了选择WebDriverJs中的下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个下拉框,我想使用WebDriverJS选择一个值。我查看了下面的用户指南,但无法了解如何操作
I have a dropdown box that I would like to select a value using WebDriverJS. I've looked at the user guide below and could not find out how to do it
我甚至尝试过为Java版本记录的一些内容,如下所示:
I even try a few things that was documented for Java version like this:
webdriver.Select(driver.findElement(webdriver.By.id("vote"))).selectByValue("5")
它只是简单地说选择不存在。
And it just simply says that "Select" does not exist.
我查看了源码,但仍找不到任何可以使用的内容。
I went through the source and still cannot find anything that I can use.
推荐答案
您无需两次单击即可选择一个选项,只需直接单击该选项即可。类似的东西,
You don't need two clicks to select an option, just click on the option directly. Something like,
driver.findElement(wd.By.css('#month>option[title=\'November\']')).click();
这篇关于选择WebDriverJs中的下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文