I have a test case that changes the time value in the dialog pop-up. To do so, I created a method named setDateInput
.
public void setDateInput(Object date, WebElement input_date, String format) throws InterruptedException { if(date == null) { //leave the date as it is. return; } else if( (date instanceof Date) ) { //arg date is passed. String new_date = new SimpleDateFormat(format).format(date); input_date.clear(); input_date.sendKeys(new_date); return; } else if(date instanceof String) { input_date.clear(); input_date.sendKeys((String)date); return; } }
When it is called by this code below, Chrome driver changed the startInput
to 23:55 but firefox does neither clear()
nor sendKeys()
.
setDateInput("23:55", startInput, "HH:mm");
So, my question is, is there a different way to handle the text type input in Firefox webdriver?
Thank you in advance.
Update: The start_time element in HTML code as following
<input type="text" id="StartTime" value="00:01" pattern="([01]?[0-9]|2[0-3]):[0-5][0-9]" placeholder="HH:MM" class="form-control input-text time-field-hm" required="" inputmode="numeric">
Advertisement
Answer
I found an answer by myself. This solution is not exactly fixing the issue but this is more of workaround.
I just added a method click()
before clear()
method. Firefox webdriver then manages to focus on that element. And it clears and sends a 23:55
String to the input field. Weird way to resolve the issue.
Or simply sendKeys("")
will do as well. Hope this helpful.