diff --git a/docs/secrets.md b/docs/secrets.md index 2653d9d97..4494575ba 100644 --- a/docs/secrets.md +++ b/docs/secrets.md @@ -15,6 +15,12 @@ When executed it will be printed like this: ``` I fill field "password" "*****" ``` +**Other Examples** +```js +I.fillField('password', secret('123456')); +I.append('password', secret('123456')); +I.type('password', secret('123456')); +``` For an object, which can be a payload to POST request, specify which fields should be masked: diff --git a/docs/webapi/appendField.mustache b/docs/webapi/appendField.mustache index 78e0c3145..b8fa8b53d 100644 --- a/docs/webapi/appendField.mustache +++ b/docs/webapi/appendField.mustache @@ -3,6 +3,8 @@ Field is located by name, label, CSS or XPath ```js I.appendField('#myTextField', 'appended'); +// typing secret +I.appendField('password', secret('123456')); ``` @param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator @param {string} value text value to append. diff --git a/docs/webapi/type.mustache b/docs/webapi/type.mustache index d1d4a9bd4..51254887d 100644 --- a/docs/webapi/type.mustache +++ b/docs/webapi/type.mustache @@ -11,6 +11,9 @@ I.type('4141555311111111', 100); // passing in an array I.type(['T', 'E', 'X', 'T']); + +// passing a secret +I.type(secret('123456')); ``` @param {string|string[]} key or array of keys to type. diff --git a/lib/helper/Nightmare.js b/lib/helper/Nightmare.js index ff180135c..23467597f 100644 --- a/lib/helper/Nightmare.js +++ b/lib/helper/Nightmare.js @@ -694,7 +694,7 @@ class Nightmare extends Helper { async appendField(field, value) { const el = await findField.call(this, field); assertElementExists(el, field, 'Field'); - return this.browser.enterText(el, value, false) + return this.browser.enterText(el, value.toString(), false) .wait(this.options.waitForAction); } diff --git a/lib/helper/Playwright.js b/lib/helper/Playwright.js index b0f30e715..854742388 100644 --- a/lib/helper/Playwright.js +++ b/lib/helper/Playwright.js @@ -1439,6 +1439,7 @@ class Playwright extends Helper { */ async type(keys, delay = null) { if (!Array.isArray(keys)) { + keys = keys.toString(); keys = keys.split(''); } @@ -1483,7 +1484,7 @@ class Playwright extends Helper { const els = await findFields.call(this, field); assertElementExists(els, field, 'Field'); await els[0].press('End'); - await els[0].type(value, { delay: this.options.pressKeyDelay }); + await els[0].type(value.toString(), { delay: this.options.pressKeyDelay }); return this._waitForAction(); } diff --git a/lib/helper/Protractor.js b/lib/helper/Protractor.js index 48f3eef85..b85e015f2 100644 --- a/lib/helper/Protractor.js +++ b/lib/helper/Protractor.js @@ -647,7 +647,7 @@ class Protractor extends Helper { async appendField(field, value) { const els = await findFields(this.browser, field); assertElementExists(els, field, 'Field'); - return els[0].sendKeys(value); + return els[0].sendKeys(value.toString()); } /** diff --git a/lib/helper/Puppeteer.js b/lib/helper/Puppeteer.js index 1187561e2..be58d7927 100644 --- a/lib/helper/Puppeteer.js +++ b/lib/helper/Puppeteer.js @@ -1262,6 +1262,7 @@ class Puppeteer extends Helper { */ async type(keys, delay = null) { if (!Array.isArray(keys)) { + keys = keys.toString(); keys = keys.split(''); } @@ -1306,7 +1307,7 @@ class Puppeteer extends Helper { const els = await findVisibleFields.call(this, field); assertElementExists(els, field, 'Field'); await els[0].press('End'); - await els[0].type(value, { delay: this.options.pressKeyDelay }); + await els[0].type(value.toString(), { delay: this.options.pressKeyDelay }); return this._waitForAction(); } diff --git a/lib/helper/TestCafe.js b/lib/helper/TestCafe.js index e63d49e3f..46ad68c17 100644 --- a/lib/helper/TestCafe.js +++ b/lib/helper/TestCafe.js @@ -410,7 +410,7 @@ class TestCafe extends Helper { const el = await els.nth(0); return this.t - .typeText(el, value, { replace: false }) + .typeText(el, value.toString(), { replace: false }) .catch(mapError); } diff --git a/lib/helper/WebDriver.js b/lib/helper/WebDriver.js index 57c82e2b1..31b6ca7d7 100644 --- a/lib/helper/WebDriver.js +++ b/lib/helper/WebDriver.js @@ -1035,7 +1035,7 @@ class WebDriver extends Helper { const res = await findFields.call(this, field); assertElementExists(res, field, 'Field'); const elem = usingFirstElement(res); - return elem.addValue(value); + return elem.addValue(value.toString()); } /** @@ -1879,6 +1879,7 @@ class WebDriver extends Helper { */ async type(keys, delay = null) { if (!Array.isArray(keys)) { + keys = keys.toString(); keys = keys.split(''); } if (delay) {