How can I select the drop down date section using selenium

0 votes
I have just started working on selenium and know only a few things. I was wondering as how can I select an element from the drop down list. I am trying things on facebook's website. The login page has a signup section and there is a dropdown option to fill date of birth how to test that and fill a date?
Dec 18, 2018 in Selenium by Anjali
• 2,950 points
11,816 views

1 answer to this question.

0 votes

First thing that you need to do is find the ID for the dropdown box you are going to test.

There is a select class used in selenium. 

Here is the eg I used to create the above said scenario:

import org.openqa.selenium.support.ui.Select;

System.setProperty("webdriver.chrome.driver","C:\\Yourpath\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.facebook.com");
Select year = new Select(driver.findElement(By.id("date")));
year.selectByVisibleText("27");
Select year = new Select(driver.findElement(By.id("month")));
year.selectByVisibleText("Aug");
Select year = new Select(driver.findElement(By.id("year")));
year.selectByVisibleText("2000");
Thread.sleep(5000);

This is not the legit way but agin this also worked so I am just giving this as an option to do things in a simpler way

System.setProperty("webdriver.chrome.driver","C:\\Yourpath\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.facebook.com");
driver.findElement(By.id("day")).sendKeys("6");
driver.findElement(By.id("month")).sendKeys("Nov");
driver.findElement(By.id("year")).sendKeys("2000");
Thread.wait(5000);

These were the two ways I know to do this.

answered Dec 19, 2018 by Nabarupa

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

How can I select date from a datepicker div using Selenium Webdriver?

Hey Jeevika, you can use following automation ...READ MORE

answered Jul 15, 2019 in Selenium by Abha
• 28,140 points
12,178 views
0 votes
1 answer

How can I download the *.jar file from http:// seleniumhq.org using selenium WebDriver?

For Selenium Standalone Server use this: profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/java-archive"); and ...READ MORE

answered Apr 9, 2018 in Selenium by Martin
• 4,320 points
3,534 views
0 votes
2 answers

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,500 points
13,673 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,142 views
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,910 points
7,221 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,874 views
0 votes
1 answer

How can I select an option from a dropdown using Ruby Selenium Webdriver?

Hey Swasti, you can try following lines ...READ MORE

answered Aug 26, 2019 in Selenium by Anvi
• 14,150 points
4,763 views
+4 votes
1 answer

How can I configure Eclipse for using Selenium?

Follow the following steps to configure your ...READ MORE

answered Dec 12, 2018 in Selenium by Nabarupa
1,865 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP