By user_ID = By.name("txtUserID");
By pwd = By.name("txtPassword");
By Login = By.xpath("//button[contains(text(),'Log In')]");
By dropdownclient = By.xpath("//select[@id='selClientSelect']");
public void select_client()
{
Select client = new Select(dropdownclient);
client.selectByValue("1");
}
但是我遇到错误“构造函数Select(By)
未定义”]
确保已导入选择:import org.openqa.selenium.support.ui.Select;
您还需要初始化WebElement,然后才能将其传递到Select构造函数中:
WebElement dropDownElement = driver.findElement(dropdownClient);
Select client = new Select(dropDownElement);