Date selection in datepicker calendar

Hi Team,

I am trying to select a dynamic date from the date picker calendar from the image attached. Till 26th my code is working correctly and as the date reached 27 Jan the system clicks on 27 Dec in place of 27th Jan because 27th Dec comes as the first element. Can anyone help or provide the code how to select 27 Jan in place of 27 Dec

The source shown is not showing the week of interest or the offending week. I assume there will be some way to tell if the 27th is in the first week or if the 27th is grayed out.

Also, sometimes you can bypass the datepicker and insert the desired date.

1 Like

Thanks, Eric for the response. We tried the second option and tried to insert the desired value but first we need to clear the default date and for that we have used the clear function. But clear function not doing its work. Please see the code below.

Can you please help to find the solution for the same.

.then(function(){
return $browser.findElement($driver.By.className(nextMonthClass)).click();
})
.then(function(){
return $browser.findElement($driver.By.xpath(’/html/body/div/div/div[1]/div/div[2]/div/div/div[1]/div[1]/div[1]/div[2]/div/div[1]/div/input’)).then(function(element){
return element.click().then(function(){
return $browser.findElement($driver.By.xpath(’/html/body/div/div/div[1]/div/div[2]/div/div/div[1]/div[1]/div[1]/div[2]/div/div[1]/div/input’)).clear();
element.sendKeys(‘2021-01-27’)
});
})

|690x387](upload://g3ApcgOKYJ1Je7GJfHFwp1LGPuk.png)

Thank you Eric from providing that insight. @satish.kumar6 were you able to find the solution or do you still need further assistance?

Hi Joi, I am still waiting for the solution to the issue of clear function which I am facing :

Please refer below :

We tried the second option and tried to insert the desired value but first, we need to clear the default date and for that, we have used the clear function. But clear function not doing its work. Please see the code below.

Can you please help to find the solution for the same?

.then(function(){
return $browser.findElement($driver.By.className(nextMonthClass)).click();
})
.then(function(){
return $browser.findElement($driver.By.xpath(’/html/body/div/div/div[1]/div/div[2]/div/div/div[1]/div[1]/div[1]/div[2]/div/div[1]/div/input’)).then(function(element){
return element.click().then(function(){
return $browser.findElement($driver.By.xpath(’/html/body/div/div/div[1]/div/div[2]/div/div/div[1]/div[1]/div[1]/div[2]/div/div[1]/div/input’)).clear();
element.sendKeys(‘2021-01-27’)
});
})

|690x387](upload://g3ApcgOKYJ1Je7GJfHFwp1LGPuk.png)

@satish.kumar6 Sorry to hear you’re still experiencing this issue. This is not my area of expertise and out of scope for our support team. I’m going to reach out to some other community members to see if they can help! Thanks for your patience :slight_smile:

I can’t offer anything additional. This is one of those things that you have to do hands on with the application and have some experience with test automation. Difficult to handle in a forum. They may want to seek help internally with some other testers.

2 Likes