It seems that Chrome / Selenium has different input type formats for different locales. For instance, the date picker (i.e. input type="date"
) is displayed as mm/dd/yyyy
in the US and yyyy-mm-dd
in Canada. This variation poses a challenge when writing specs that need to work across different locale settings. For example:
find("input[type='date']").set("12/31/2016") # works in Canada, but not in America
find("input[type='date']").set("2017-12-31") # works in America, but not in Canada
Is there a way to set Capybara / Selenium to use a specific locale or formatting for inputs? Alternatively, is it feasible to detect the format of an input using JS and then replace it with a page.execute_script
(attempting to set it to
input.val(new Date(2016, 12, 31))
doesn't seem to work)?