Skip to content

Commit e29ea4b

Browse files
reubenmillerDavertMik
authored andcommitted
[Bugfix #932] Clear value attribute instead of innerhtml for TEXTAREA elements (#935)
* Lint fix * [Puppeteer] Fixed clearing the text value in TEXTAREA by setting the value attribute instead of the innerhtml. Fixes #932
1 parent 9fb4144 commit e29ea4b

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

lib/helper/Puppeteer.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -749,12 +749,10 @@ class Puppeteer extends Helper {
749749
// await el.focus();
750750
const tag = await el.getProperty('tagName').then(el => el.jsonValue());
751751
const editable = await el.getProperty('contenteditable').then(el => el.jsonValue());
752-
753-
if (tag === 'TEXTAREA' || editable) {
754-
await this._evaluateHandeInContext(el => el.innerHTML = '', el);
755-
}
756-
if (tag === 'INPUT') {
752+
if (tag === 'INPUT' || tag === 'TEXTAREA') {
757753
await this._evaluateHandeInContext(el => el.value = '', el);
754+
} else if (editable) {
755+
await this._evaluateHandeInContext(el => el.innerHTML = '', el);
758756
}
759757
await el.type(value, { delay: 10 });
760758
return this._waitForAction();

lib/interfaces/bdd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ module.exports = function (suite) {
6464
Object.keys(deps).forEach((key) => {
6565
test.inject[key] = deps[key];
6666
});
67-
}
67+
};
6868
test.file = file;
6969
test.async = true;
7070
test.timeout(0);

test/helper/webapi.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,14 @@ module.exports.tests = function () {
319319
return assert.equal(formContents('description'), 'Nothing special');
320320
});
321321

322+
it('should fill textarea by overwritting the existing value', function* () {
323+
yield I.amOnPage('/form/textarea');
324+
yield I.fillField('Description', 'Nothing special');
325+
yield I.fillField('Description', 'Some other text');
326+
yield I.click('Submit');
327+
return assert.equal(formContents('description'), 'Some other text');
328+
});
329+
322330
it('should append field value', function* () {
323331
yield I.amOnPage('/form/field');
324332
yield I.appendField('Name', '_AND_NEW');

0 commit comments

Comments
 (0)