1

I am trying to select an element from dropdown with text as Ad. My page has a telerik dropdown and this is the HTML Code.

enter image description here

I am running following code:

SelectElement IDdropdown = new SelectElement(driver.FindElement(TrackingEnrityID_Dropdown));
IDdropdown.SelectByText("Ad");

and throws this runtime error:

An exception of type 'OpenQA.Selenium.Support.UI.UnexpectedTagNameException' occurred in WebDriver.Support.dll but was not handled in user code

Additional information: Element should have been select but was span

1 Answer 1

2

The problem is the element you are working on is NOT embedded in a select tag, so you can't use Select class on that element. When you use a Select class, a check is made that the given element is, indeed, a SELECT tag. If it is not, then an UnexpectedTagNameException is thrown.

So, what you can do is:

  1. Identify the locator for the element.
  2. Perform a click on the element.
  3. identify the locator for the element from the dropdown and click on the required element. You can't use any of the select class methods like select_by_index or by select_by_visible_text etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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