我正在尝试从Selenium中带有Span标签的Dropdown中选择一个选项。下面是我的硒代码
new Select (driver.findElement(By.cssSelector("span.select2-selection.select2-selection--single"))).selectByVisibleText("Prison");
遇到错误'org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "span"'
下拉菜单的HTML代码如下;
请寻求任何帮助。
答案 0 :(得分:0)
您不能在选择课程中使用。尝试
Select sel = new Select(driver.findelement(By.id('P37_ACCOMMODATION_STATUS')));
sel.SelectByVisibleText('Prision');