I want to automate that starting date and end date but in DOM I can't find a Table tag for date picker so I don't know how to locate the field.
The tag is
<input class="inputvd" type="date" name="starting date" value="2023-08-24">
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It only takes a minute to sign up.
Sign up to join this communityIt's possible - and often done - to have a webpage render something that looks like a table but doesn't use a table tag.
What you want is to identify the field that you're looking for.
In your case it isn't too difficult: you have an input element with a name that ought to be unique in the page.
So, you can locate the starting date field with:
WebElement startDate = driver.findElement(ByName("starting date"));
End date would be similar.
Since both are input elements, all you have to do to set the dates is to call sendKeys()
:
startDate.sendKeys("2023-03-01");
You don't actually need to simulate clicking into the calendar widget unless you have to validate that you can click on specific dates.
As a general rule, when you are automating user interface interactions, look for the simplest way to get the results you need. Sometimes it's best to step back and think about what you are trying to do before you dive in and try to code it.
It's always helpful to work through a few courses on the language you are using to code your tests - the better you are with the language, the better your automation code will be.
In test automation services we can achieve this multiple way like using action class and by updating the value in the attribute. It all depend how developer implemented the date picker. Some simple way are as follow.