Not able to select date from date picker using selenium webdriver

Viewed 1616

I am not able to select data from the calendar because it is not having the id's to select.

below is my HTML code,

enter image description here

enter image description here

The Code I tried is

 DateDOB = By.xpath("//*[@id='dob']")
strDateDOB="12/12/2020"
driver.findElement(DateDOB).sendKeys(strDateDOB);

but unable to select the date

Url to the application :

http://demo.guru99.com/V4/

username : mgr123 Password : mgr!23

Click on the New Account from the Left Pane to select the above discussed desired page.

Can any one please help in selecting the date?

1 Answers

DOB has the id. sendKeys works. Don't use XPATH when ID is present.

I tried the following code and it is entering DOB value:

@Test
public void tst1() {
    WebDriver driver = new FirefoxDriver();
    driver.get("http://demo.guru99.com/V4/");
    driver.findElement(By.name("uid")).sendKeys("mgr123");
    driver.findElement(By.name("password")).sendKeys("mgr!23");
    driver.findElement(By.name("btnLogin")).click();
    driver.findElement(By.linkText("New Customer")).click();
    driver.findElement(By.id("dob")).sendKeys("12/12/2018");
    sleep(5000);

}
Related