Headless chrome deletes input value - Datetime field

Viewed 217

So, I am running some tests in headless chrome with selenium, but in headless mode the input value from this datetime field getting deleted(after its been sent) in the running process. In normal running with head the executions are okay. The datetime field is a Date type and YYYYMMDD form. date.sendKeys("19600202"); --> this is getting deleted.

But when I am sending this way, the values not getting deleted and tests runs okay:

date.sendKeys("1960");
date.sendKeys("02");
date.sendKeys("02");

Any suggestions, how can i send the Date in one sendkey or should i use js? Thank you. This is the field:

<input type="text" id="Date" ctrl_type="datetime-input" name="Date" maxlength=10 data-format="L" data-io-format="YYYYMMDD" data-today-button="false" data-clear-button="false" data-close-button="false" data-disable-weekends="false" data-inline="false" class="  form-control " data-toggle="tooltip" data-placement="top" data-original-title="" aria-describedby="_sys_invalidation-message-Date">
1 Answers

The desired element is an Angular element so to locate/click() on the element you need to induce WebDriverWait for the elementToBeClickable() and you can use either of the following Locator Strategies:

  • cssSelector:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input.form-control#Date[name='Date']"))).sendKeys("19600202");
    
  • xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='Date' and @name='Date'][@ctrl_type='datetime-input']"))).sendKeys("19600202");
    
Related