Selecting a dropdown value in Selenium WebDriver

0 votes

I want to select a value from the drop down. The id=dropdownId and I am trying to select Last 52 weeks.

Html tag:

<select id=" dropdownId " name="period" style="display: none;">
<option value="l4w">Last 4 Weeks</option>
<option value="l52w">Last 52 Weeks</option>
<option value="daterange">Date Range</option>
<option value="weekrange">Week Range</option>
<option selected="" value="monthrange">Month Range</option>
<option value="yeartodate">Year To Date</option>
</select>

M not able to click the drop down as I m getting an error: - Element is not currently visible and so may not be interacted with Command duration or timeout: 32 milliseconds the drop downs values are the jquery multiselect widget format

Apr 9, 2018 in Selenium by nsv999
• 5,030 points
600 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Try to wrap your WebElement as shown below

Select dropdown = new Select(driver.findElement(By.id("identifier")));

After this select the required value in 3 ways. Consider an HTML file like this

<html>
<body>
<select id = "designation">
<option value = "MD">MD</option>
<option value = "prog"> Programmer </option>
<option value = "CEO"> CEO </option>
</option>
</select>
<body>
</html>

Now to identify dropdown use

Select dropdown = new Select(driver.findElement(By.id("designation")));

And to select its option say 'Programmer' you can do

dropdown.selectByVisibleText("Programmer ");

or

dropdown.selectByIndex(1);

or

 dropdown.selectByValue("prog");
answered Apr 9, 2018 by QueenBee
• 1,810 points

Related Questions In Selenium

0 votes
1 answer

Double click a record in a grid using Selenium webdriver

Try Actions class to perform this Actions action ...READ MORE

answered Mar 29, 2018 in Selenium by Damon Salvatore
• 5,250 points
592 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Selecting an item from dropdown list using Selenium WebDriver & java

Use the below code: new Select(driver.findElement(By.id("blood-group"))).selectByVisibleText("AB"); You also need ...READ MORE

answered May 8, 2018 in Selenium by Meci Matt
• 9,400 points
1,286 views
0 votes
1 answer

Using keys (Ctrl+A) in Selenium WebDriver

You can use the below code: String select ...READ MORE

answered May 9, 2018 in Selenium by Meci Matt
• 9,400 points
977 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,030 points
66 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
438 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
52 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.