0

For dropdown list I use the below code

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

But this error occured

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

https://www.w3schools.com/tags/tag_select.asp

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.