New here and need some advice if you would be so kind.

So I am getting the hang of automation testing and am attempting to automate the registration process by providing an excel CSV and have the program pull and play into the fields. All works well except for the DOB field. It seems the text selenium tries to insert, only gets inserted into the Year field. (If I send sendKeys("2020-01-01") only DD-MM-2020 get entered. It seems the DOB element is all tied together (the month, day, and year fields are all one element) and I am stumped on how I would be able to automate this portion using Selenium Java.

You can find the DOB field on https://www.demo.guru99.com/V4/manager/addcustomerpage.php

DOB field screenshot

Here is the code from inspector

<td><input type="date" name="dob" id="dob" onkeyup="validatedob();" onblur="validatedob();">
  <label id="message24" style="visibility: visible;">Date Field must not be blank</label>

In a lame effort, I was curious as to how selenium recorder handled this so I recorded the same scenario and the script it writes works in Selenium Recorder but not when it is exported to Junit script.

Selenium Recorder generated script for DOB field:


Pasting this code into the java program yields the same mm-dd-2020.

I DO NOT want to use the calendar to input the date as I suspect that would be a pain.

Appreciate any help, Andy

1 Answer 1


After a few days of searching and debugging, I have finally found a solution. Find the element of the Date box, set it to a variable without clicking in it and send keys as follows:

WebElement dateBox = driver.findElement(By.xpath("//*[@id='dob']"));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.