答案 0 :(得分:0)
您发布的代码存在一些问题。稍微清理它可能会有效,但Selenium通过Select
提供的方法可以利用。
String expectedValue = "Adverstising Services";
Select dropDown = new Select(driver.findElement(By.xpath(".//*[@id='select2-chooseInd-container']")));
dropDown.selectByVisibleText(expectedValue);
您可以在此处详细了解Select
以及文档中提供的方法:https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/Select.html