Here I am trying to select a value from dropdown using selenium script but I got this error in the console like
"Exception in thread "main" org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "span"..
public class HomeUserManagement {
public static void main(String args[]) {
System.setProperty("webdriver.chrome.driver",
"C:\Users\UMASHANKAR\Documents\selenuim\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.manage().window().maximize();
//for login
driver.get("https://ecabportal.azurewebsites.net/dashboard");
driver.findElement(By.name("email")).sendKeys("[email protected]");
driver.findElement(By.name("password")).sendKeys("abc123xyz");
driver.findElement(By.name("signIn")).click();
//actual code for selecting a value from dropdown
driver.get("https://ecabportal.azurewebsites.net/user");
Select drpdwn=new Select(driver.findElement(By.id("select2-signup-username-container")));
drpdwn.selectByVisibleText("User Name");
drpdwn.selectByIndex(0);
there are multiple values in a dropdown I need to select one value in that..
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…