Skip to content

Commit de8e0d4

Browse files
anils92anilwk
andauthored
Added secret support to append() and type() (#3615)
Co-authored-by: Sharma, Anil <[email protected]>
1 parent 5a549b6 commit de8e0d4

File tree

9 files changed

+20
-6
lines changed

9 files changed

+20
-6
lines changed

docs/secrets.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ When executed it will be printed like this:
1515
```
1616
I fill field "password" "*****"
1717
```
18+
**Other Examples**
19+
```js
20+
I.fillField('password', secret('123456'));
21+
I.append('password', secret('123456'));
22+
I.type('password', secret('123456'));
23+
```
1824

1925
For an object, which can be a payload to POST request, specify which fields should be masked:
2026

docs/webapi/appendField.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Field is located by name, label, CSS or XPath
33

44
```js
55
I.appendField('#myTextField', 'appended');
6+
// typing secret
7+
I.appendField('password', secret('123456'));
68
```
79
@param {CodeceptJS.LocatorOrString} field located by label|name|CSS|XPath|strict locator
810
@param {string} value text value to append.

docs/webapi/type.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ I.type('4141555311111111', 100);
1111

1212
// passing in an array
1313
I.type(['T', 'E', 'X', 'T']);
14+
15+
// passing a secret
16+
I.type(secret('123456'));
1417
```
1518

1619
@param {string|string[]} key or array of keys to type.

lib/helper/Nightmare.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ class Nightmare extends Helper {
694694
async appendField(field, value) {
695695
const el = await findField.call(this, field);
696696
assertElementExists(el, field, 'Field');
697-
return this.browser.enterText(el, value, false)
697+
return this.browser.enterText(el, value.toString(), false)
698698
.wait(this.options.waitForAction);
699699
}
700700

lib/helper/Playwright.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,7 @@ class Playwright extends Helper {
14391439
*/
14401440
async type(keys, delay = null) {
14411441
if (!Array.isArray(keys)) {
1442+
keys = keys.toString();
14421443
keys = keys.split('');
14431444
}
14441445

@@ -1483,7 +1484,7 @@ class Playwright extends Helper {
14831484
const els = await findFields.call(this, field);
14841485
assertElementExists(els, field, 'Field');
14851486
await els[0].press('End');
1486-
await els[0].type(value, { delay: this.options.pressKeyDelay });
1487+
await els[0].type(value.toString(), { delay: this.options.pressKeyDelay });
14871488
return this._waitForAction();
14881489
}
14891490

lib/helper/Protractor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ class Protractor extends Helper {
647647
async appendField(field, value) {
648648
const els = await findFields(this.browser, field);
649649
assertElementExists(els, field, 'Field');
650-
return els[0].sendKeys(value);
650+
return els[0].sendKeys(value.toString());
651651
}
652652

653653
/**

lib/helper/Puppeteer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,7 @@ class Puppeteer extends Helper {
12621262
*/
12631263
async type(keys, delay = null) {
12641264
if (!Array.isArray(keys)) {
1265+
keys = keys.toString();
12651266
keys = keys.split('');
12661267
}
12671268

@@ -1306,7 +1307,7 @@ class Puppeteer extends Helper {
13061307
const els = await findVisibleFields.call(this, field);
13071308
assertElementExists(els, field, 'Field');
13081309
await els[0].press('End');
1309-
await els[0].type(value, { delay: this.options.pressKeyDelay });
1310+
await els[0].type(value.toString(), { delay: this.options.pressKeyDelay });
13101311
return this._waitForAction();
13111312
}
13121313

lib/helper/TestCafe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ class TestCafe extends Helper {
410410
const el = await els.nth(0);
411411

412412
return this.t
413-
.typeText(el, value, { replace: false })
413+
.typeText(el, value.toString(), { replace: false })
414414
.catch(mapError);
415415
}
416416

lib/helper/WebDriver.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ class WebDriver extends Helper {
10351035
const res = await findFields.call(this, field);
10361036
assertElementExists(res, field, 'Field');
10371037
const elem = usingFirstElement(res);
1038-
return elem.addValue(value);
1038+
return elem.addValue(value.toString());
10391039
}
10401040

10411041
/**
@@ -1879,6 +1879,7 @@ class WebDriver extends Helper {
18791879
*/
18801880
async type(keys, delay = null) {
18811881
if (!Array.isArray(keys)) {
1882+
keys = keys.toString();
18821883
keys = keys.split('');
18831884
}
18841885
if (delay) {

0 commit comments

Comments
 (0)