Skip to content

Instantly share code, notes, and snippets.

@MattiSG
Last active Feb 5, 2016
Embed
What would you like to do?
ChromeDriver issue reproduction

With a running ChromeDriver:

git clone https://gist.github.com/4805526b5dcea0897c27.git
npm install selenium-webdriver
node index.js
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ChromeDriver sendKeys() won't work on an input type="date" after a clear</title>
</head>
<body>
<h1>ChromeDriver <code>clear</code> on an <code>input type="date"</code> pretends element is not user-editable</h1>
<input type="date" name="date"></input>
<code>
<pre>
driver.findElement(By.name('date')).sendKeys('01012016');
driver.findElement(By.name('date')).clear();
/** Throws:
InvalidElementStateError: invalid element state: Element must be user-editable in order to clear it.
(Session info: chrome=48.0.2564.103)
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.11.3 x86_64)
*/
driver.findElement(By.name('date')).sendKeys('02022016');
</pre>
</code>
</body>
</html>
var webdriver = require('selenium-webdriver'),
By = require('selenium-webdriver').By;
var driver = new webdriver.Builder()
.forBrowser('chrome')
.build();
driver.get('file://' + __dirname + '/index.html');
driver.findElement(By.name('date')).sendKeys('01012016');
driver.findElement(By.name('date')).clear();
driver.findElement(By.name('date')).sendKeys('02022016');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment