Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/org/labkey/test/WebDriverWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -3709,6 +3709,9 @@ private void setHtml5Input(WebElement input, String inputType, String value)
case "date":
setHtml5DateInput(input, value);
break;
case "datetime-local":
setHtml5DateTimeInput(input, value);
break;
case "password":
case "search":
setInput(input, value); // These don't require special handling, don't output warning
Expand Down Expand Up @@ -3737,6 +3740,21 @@ private void setHtml5DateInput(WebElement el, String text)
}
}

private void setHtml5DateTimeInput(WebElement el, String text)
{
String inputFormat = "yyyy-MM-dd'T'HH:mm";
SimpleDateFormat inputFormatter = new SimpleDateFormat(inputFormat);

try
{
setHtml5DateTimeInput(el, inputFormatter.parse(text));
}
catch (ParseException e)
{
throw new IllegalArgumentException("Unable to parse date " + text + ". Format should be " + inputFormat);
}
}

private void setHtml5DateInput(WebElement el, Date date)
{
// Firefox requires ISO date format (yyyy-MM-dd)
Expand All @@ -3749,6 +3767,18 @@ private void setHtml5DateInput(WebElement el, Date date)
el.sendKeys(formDate);
}

private void setHtml5DateTimeInput(WebElement el, Date date)
{
// Firefox and Chrome want different formats, neither of which align with all online guidance to use ISO-style
String formFormat = isFirefox() ? "MMddyyyy hh:mm a" : "MM-dd-yyyy'\t'hh:mma";
SimpleDateFormat formFormatter = new SimpleDateFormat(formFormat);
String formDate = formFormatter.format(date);

fireEvent(el, SeleniumEvent.focus);
executeScript("arguments[0].value = ''", el);
el.sendKeys(formDate);
}

private void setHtml5NumberInput(WebElement el, String text)
{

Expand Down