Skip to content

Instantly share code, notes, and snippets.

@MattiSG
Last active November 3, 2015 08:59
Show Gist options
  • Save MattiSG/0cb11f94237a414c6872 to your computer and use it in GitHub Desktop.
Save MattiSG/0cb11f94237a414c6872 to your computer and use it in GitHub Desktop.
Selenium issue reproduction case
description: 'Invalid fields should be clearable',
steps: [
InputComponent.setValidatedField('2'),
{ 'InputComponent.validatedField': '2' },
InputComponent.setValidatedField('e'),
{ 'InputComponent.validatedField': 'e' },
InputComponent.setValidatedField('3'),
{ 'InputComponent.validatedField': '3' }, // fails: `e` was invalid, the field is not cleared and contains `e3`
]
module.exports = {
baseURL: 'file://' + __dirname + '/index.html',
views: 'Verbose'
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Selenium clear() won't work on an invalidated input</title>
</head>
<body>
<h1>Selenium clear() won't work on an invalidated input</h1>
<input type="number" name="number" step="1"></input>
</body>
</html>
validatedField: 'input'
var webdriver = require('selenium-webdriver'),
By = require('selenium-webdriver').By,
until = require('selenium-webdriver').until;
var driver = new webdriver.Builder()
.forBrowser('firefox')
.build();
driver.get('file://' + __dirname + '/index.html');
driver.findElement(By.name('number')).sendKeys('2');
driver.findElement(By.name('number')).clear();
driver.findElement(By.name('number')).sendKeys('e');
driver.findElement(By.name('number')).clear();
driver.findElement(By.name('number')).sendKeys('3'); // `e` was invalid, the field is not cleared and now contains `e3`
driver.wait(() => {}, 5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment