Why refreshing a page acts randomly on a date value on Selenium/PHPUnit?

Viewed 26

I'm writing an automated test using phpUnit and the scenario is the following:

The browser shows up, a date is picked (ex : 2021-10-28), the page is refreshed.

Sometimes it shows up the right date which is 2021-10-28, and sometimes it shows a wrong date which is 1901-12-13.

Image showing a positive result

Image showing a negative result

The weird thing is that it is so random, maybe it picks an invalid value and then the input is set to minimum value so it shows 1901-12-13 ?

Here's the code :

$date=strtotime("+ 7 days");
$inputDate = date("mdY", $date);
$outputDate = date("Y-m-d", $date); 

$this->byId('template_settings_date_end')->value($inputDate); //
$this->refresh();
$this->assertEquals($outputDate, $this->byId('template_settings_date_end')->value()); // sometime displays '1901-12-13'

I tried to output the value before the refresh() and after it, it seems that the random job is done by the refresh() method.

Thank you in advance.

0 Answers
Related