I have acceptance tests that enter data on a page with a jQuery UI Datepicker.
For some reason, the datepicker is being opened when an unrelated input field has data entered. This results in other elements being obscured and unclickable later in the test.
The tests are using Google's Accessibility Developer Tools through a listener triggered when data is entered using ChromeDriver's sendKeys(). It looks like this may be focusing the datepicker element but not unfocusing it.
Is there something in the way that the datepicker or the accessibility tools work that would lead to this behaviour?
When the accessibility script is run (axs_testing.js), it checks if each element is visible by calling focus() on each element. The problem occurs when datepicker is focused (opens the dialog), then when a different element is focused on afterwards, the dialog doesn't close.
This is because it has no trigger to close when the field loses focus. If it did, the calendar would disappear as soon as you click on it as the focus would change away from the field and cause that trigger to occur.
A solution to this is to modify the accessibility script so that where it calls focus(), you add a check to see if it's trying to focus on the datepicker then (making sure it wasn't already focused) you close the datepicker dialog afterwards.