For dropdown list I use the below code

SelectElement select = new SelectElement(driver.FindElement(By.ClassName("select2-search__field")));

But this error occured

OpenQA.selenium.support.ui.UnexpectedTagNameException: 'Element should have been "select" but was input'
  • Please paste your HTML code here. Probably your dropdown doesn't contains select tag. May 12 '20 at 5:45


Read the above link to know what is select tag in HTML ,

The select could only be used for 'select' tag. As in your question your class is 'select2-search__field' its not a select tag and more over looks like a search field to search for drop down content.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.