**enter image description here**

I am using below script to retrieve specific item from drop down but it's not working.

Select  salTitle =  new Select(driver.findElement(By.id("s2id_QuickEnquiryForm_salutation")));

showing below Error in console "Exception in thread "main" org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "div""

I am using selenium + javascript.can anyone here suggest a method to select an item from a dropdown menu.

I welcome any input!

please find the Below attched Images for HTML,Source Code.enter image description here

  • Your code looks fine for me, make sure you are using correct id of dropdown. Do you getting any error? Commented Dec 23, 2014 at 9:23
  • are you using webdriverjs?
    – saifur
    Commented Dec 23, 2014 at 13:45
  • I would like to see the html of the page
    – saifur
    Commented Dec 23, 2014 at 14:14
  • I'm not getting any error & not highlighting value in field also.if you have any better idea can you please give valuable suggetsions.
    – Uday Reddy
    Commented Dec 23, 2014 at 14:16

5 Answers 5


I'm not sure how "yours" dropdown works, but for me "working solution" in similar case is:

for (j=0; ; j++)
if (Driver.FindElement(By.XPath("li[j] element")).GetElementText().Equals(should_to_select_value);
       if (Driver.FindElement(By.XPath("li[j] element")).Click();

Also, I'm sorry for example not in javascript...

  • I guess you meant to write Equals not Equials
    – saifur
    Commented Dec 23, 2014 at 13:43

There are two problems

  1. Looks like your search option is wrong. So better to use xpath for that.
  2. You can just sendkeys to dropdown like in example below


client.findElement({ xpath: '//*[@id="form-tab-1"]/div/div[1]/select' }).sendKeys(Mr.);

try this if drop down has search functionality

driver.findelement(by.xpath("your drop down arrow button or select button path")).click
driver.findelement(by.xpath("your drop down search text box path")).sendkeys("values ");
driver.findelement(by.xpath("your drop down search text box path")).sendkeys(Keys.arrowdown, keys.enter);

I was getting same error but I resolved it with the below piece of code,


Finally I am able to get "August" month automatically.


For selecting a drop-down value, I have one of the working solutions.take the XPath of the dropdown and edit the drop-down XPath like below

(....)/select/option[@value=' ']

' ' - indicates that enter your option to select from drop-down

Now by using this XPath use the click() method to select an option from drop-down

I hope it is useful for you.

Please mark it correct if it works for you

  • That doesn't really answer his scenario. Can you give more of a reasoning why you are using that method and maybe a bit of further reading so they can understand the background?
    – ECiurleo
    Commented Nov 24, 2015 at 15:53

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.