[header files [] [1] 1 seelnium webdriver 错误 线程" main"中的例外情况java.lang.NoClassDefFoundError:org / openqa / selenium / support / ui / Select(错误名称:org / openqa / selenium / support / ui / select)
代码尝试: -
Select select = new Select(driver.findElement(By.cssSelector("body > app-root > app-patient-index > app-patient-profile > div.s_detail_doc_wrapper > div.s_patient_detail_tab > div > tabset > div > tab.active.tab-pane > form > div > div.s_patient_profile_form > div > div.col-md-9 > ul > li:nth-child(2) > div > div.col-md-9 > div > div.col-sm-5.pl0 > select")));
select.deselectAll();
select.selectByVisibleText("Married");
enter image description here 在此处输入图像描述
答案 0 :(得分:0)
请使用以下代码从下拉列表中选择值。
注意:如果下拉列表是select。
类型要使用的导入是。
import org.openqa.selenium.support.ui.Select;
System.setProperty("webdriver.chrome.driver","Drivers/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.facebook.com/");
Thread.sleep(3000);
Select dayDropDown = new Select(driver.findElement(By.xpath("//select[@name='birthday_day']")));
dayDropDown.selectByVisibleText("5");
答案 1 :(得分:0)
在您缺少的elenium-support jar中找不到Select类。
您可以直接下载jar,例如版本2.0a7: http://central.maven.org/maven2/org/seleniumhq/selenium/selenium-support/2.0a7/selenium-support-2.0a7.jar
或添加maven依赖项
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-support -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>2.0a7</version>
</dependency>