【发布时间】:2019-09-25 10:26:31
【问题描述】:
我想使用 selenium 从下拉列表中选择一个值。 值为“其他”见图片
下拉列表的 xpath 是://nz-select[@formcontrolname='selectedIntegrationTypes']
这是我的代码:
public static void selectDropDownByXpath()
{
WebDriver driver2 = WebDriverMgr.getDriver();
Select dropDown = new Select(driver2.findElement(By.xpath("//nz-select[@formcontrolname='selectedIntegrationTypes']")));
dropDown.selectByVisibleText("Other");
}
我收到此错误消息:
org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "nz-select"
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'PC', ip: '12.35.12.65', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_65'
Driver info: driver.version: unknown
有人可以告诉我如何从下拉列表中选择值吗? 问候
【问题讨论】:
-
请不要发布截图请提供文本格式的DOM元素。?
标签: selenium selenium-webdriver xpath selenium-chromedriver