【发布时间】:2021-08-12 11:30:57
【问题描述】:
以下是我用来使用 nightwatch 从下拉列表中选择值的方法。如您所见,这不是一个好方法。除非我们单击确切的元素,否则我们无法从下拉列表中选择特定值。
this.useXpath();
this.click('(//td[@class="styles_selectDropdownContainer__2Vrns"])[1]')
this.useCss();
this.click('#react-select-6-option-1')
在 selenium java 中有一个很好的选择,如下所示
Select fruits = new Select(driver.findElement(By.id("fruits")));
fruits.selectByVisibleText("Banana");
我想知道有没有类似的方法也可以用在守夜人中?
【问题讨论】:
-
如果 HTML 有下拉选择和选项,那么您可以使用您共享的 Java -selenium 代码。但是 HTML 没有 Select 和 options 标签,即使这样在 Java 中完成也是一项微不足道的工作
-
你能分享一下HTML代码以便更好地理解吗?
-
@cruisepandey 完成。
标签: javascript node.js selenium automation nightwatch.js