Not able to select drop down value

2,625 views
Skip to first unread message

mrigank ved

unread,
Jan 30, 2013, 5:34:14 AM1/30/13
to seleniu...@googlegroups.com
Hi All,

I am not able select dropdown value.

Scripted as:

element=driver.findElement(By.id("Ticket_classification"));
Select clickThis=new Select(element);
clickThis.selectByValue("Down");


But showing below error but value what i am giving is correct

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Cannot locate option with value: Down
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html

Please Help me

Regards,
Mrigank

Mayank Srivastava

unread,
Jan 30, 2013, 5:43:34 AM1/30/13
to seleniu...@googlegroups.com
Hi Mrigank,

You can try two way to select value in field-

First-

driver.findElement(By.XPath(xyz)/option[2]).click();

Second-

Select drop = new Select (driver.findElement(By.xpath ("xyz']")));
               
drop.selectByIndex(2);

Let me know if it works.

Mayank

mrigank ved

unread,
Jan 30, 2013, 5:47:38 AM1/30/13
to seleniu...@googlegroups.com
Hi Mayank,

With second it worked.
thanks Mayank.

Mark Collin

unread,
Jan 30, 2013, 9:33:40 AM1/30/13
to seleniu...@googlegroups.com
Is the value really down?  or is the visibleText down? Do you really want to:

clickThis.selectByVisibleText("Down");
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/a0va7ABy_IAJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

mriga...@gmail.com

unread,
Jan 30, 2013, 9:54:31 AM1/30/13
to seleniu...@googlegroups.com
Yes colin

But when I am using .selectByIndex(); it is working.

Mrigank
Sent on my BlackBerry® from Vodafone

From: Mark Collin <mark....@lazeryattack.com>
Date: Wed, 30 Jan 2013 14:33:40 +0000
Subject: Re: [selenium-users] Not able to select drop down value

skd

unread,
Jun 7, 2013, 11:30:29 AM6/7/13
to seleniu...@googlegroups.com
I'm having a similar problem where selectByVisibleText("Default") does not work but selectByIndex(1) does.  I don't see any error when selectByVisibleText is called, it just doesn't change the selection in the dropdown.

<select id="skill_model_select" name="skill_model" title="Sorted by AIC, ascending."><option value="11232" title="Export7">
      Export7
   
</option><option value="603" title="Default">
      Default
   
</option><option value="13292" title="Single-KC">
      Single-KC
   
</option><option value="13293" title="Unique-step">
      Unique-step
   
</option>
</select>

I'm using selenium-server-standalone-2.33.0.jar with Firefox 20.0.1.  I also tried 2.32.0 with the same results.

skd

unread,
Jun 7, 2013, 3:48:53 PM6/7/13
to seleniu...@googlegroups.com
Well, this is interesting...  I found that if I call selectByVisibleText twice, with a slight delay between calls, it works. Any theories as to why it doesn't work on the first call?  Has anyone else had to do similar workarounds?

Thanks!

robbiewinston

unread,
Jun 10, 2013, 6:05:27 AM6/10/13
to seleniu...@googlegroups.com
Could the drop down list is hidden by javascript, and a mouse over event or the like required to display the list on screen?

Webdriver cannot interact (by design) with objects that are not visible to the user (obviously not including javascript firing here!)

skd

unread,
Jun 11, 2013, 10:58:16 AM6/11/13
to seleniu...@googlegroups.com
It turns out that something changed in the UI. Where I used to be able to use the id "skill_model_select", I now have to get the Select element as "(//select[@id='skill_model_select'])[2]".  I'll have to talk to the developers about what's changed and why.

Thanks.
Reply all
Reply to author
Forward
0 new messages