Skip to content

Commit 4c572df

Browse files
committed
fix(commands): fix addCommand and overvriteCommand examples
1 parent d012d1d commit 4c572df

File tree

4 files changed

+111
-50
lines changed

4 files changed

+111
-50
lines changed

docs/commands/browser/addCommand.mdx

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,43 @@ Use the `addCommand` command to add your own command to the browser or to an ele
1414
## Usage {#usage}
1515

1616
```javascript
17-
await browser.addCommand(name, callback, elementScope);
17+
browser.addCommand(name, callback, elementScope);
1818
```
1919

2020
## Command Parameters {#parameters}
2121

2222
<table>
23-
<thead>
24-
<tr><td>**Name**</td><td>**Type**</td><td>**Description**</td></tr>
25-
</thead>
26-
<tbody>
27-
<tr><td>name</td><td>String</td><td>Custom command name.</td></tr>
28-
<tr><td>callback</td><td>Function</td><td>Command implementation function.</td></tr>
29-
<tr><td>elementScope</td><td>Boolean</td><td>If the value is _true_, add the command to the element instead of the browser. Default: _false_.</td></tr>
30-
31-
</tbody>
23+
<thead>
24+
<tr>
25+
<td>**Name**</td>
26+
<td>**Type**</td>
27+
<td>**Description**</td>
28+
</tr>
29+
</thead>
30+
<tbody>
31+
<tr>
32+
<td>name</td>
33+
<td>String</td>
34+
<td>Custom command name.</td>
35+
</tr>
36+
<tr>
37+
<td>callback</td>
38+
<td>Function</td>
39+
<td>Command implementation function.</td>
40+
</tr>
41+
<tr>
42+
<td>elementScope</td>
43+
<td>Boolean</td>
44+
<td>If the value is _true_, add the command to the element instead of the browser. Default: _false_.</td>
45+
</tr>
46+
</tbody>
3247
</table>
3348

3449
## Usage Examples {#examples}
3550

3651
```javascript
3752
// add the getUrlAndTitle command
38-
await browser.addCommand("getUrlAndTitle", async function (customParam) {
53+
browser.addCommand("getUrlAndTitle", async function (customParam) {
3954
return {
4055
url: await this.getUrl(), // `this` here and below refers to the "browser" object
4156
title: await this.getTitle(),
@@ -45,14 +60,14 @@ await browser.addCommand("getUrlAndTitle", async function (customParam) {
4560

4661
// use the new getUrlAndTitle command
4762
it("should use my add command", async ({ browser }) => {
48-
await browser.url("https://webdriver.io");
63+
await browser.url("https://testplane.io");
4964

5065
const result = await browser.getUrlAndTitle("foobar");
5166

52-
assert.strictEqual(result.url, "https://webdriver.io");
67+
assert.strictEqual(result.url, "https://testplane.io");
5368
assert.strictEqual(
5469
result.title,
55-
"WebdriverIO · Next-gen browser and mobile automation test framework for Node.js",
70+
"Testplane Docs | Testplane Docs",
5671
);
5772
assert.strictEqual(result.customParam, "foobar");
5873
});

docs/commands/browser/overwriteCommand.mdx

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,41 @@ await browser.overwriteCommand(name, callback, elementScope);
1919
## Command Parameters {#parameters}
2020

2121
<table>
22-
<thead>
23-
<tr><td>**Name**</td><td>**Type**</td><td>**Description**</td></tr>
24-
</thead>
25-
<tbody>
26-
<tr><td>name</td><td>String</td><td>The name of the custom command.</td></tr>
27-
<tr><td>callback</td><td>Function</td><td>The function implementation of the command.</td></tr>
28-
<tr><td>elementScope</td><td>Boolean</td><td>If the value is _true_, add the command to the element instead of the browser. Default: _false_.</td></tr>
29-
30-
</tbody>
22+
<thead>
23+
<tr>
24+
<td>**Name**</td>
25+
<td>**Type**</td>
26+
<td>**Description**</td>
27+
</tr>
28+
</thead>
29+
<tbody>
30+
<tr>
31+
<td>name</td>
32+
<td>String</td>
33+
<td>The name of the custom command.</td>
34+
</tr>
35+
<tr>
36+
<td>callback</td>
37+
<td>Function</td>
38+
<td>The function implementation of the command.</td>
39+
</tr>
40+
<tr>
41+
<td>elementScope</td>
42+
<td>Boolean</td>
43+
<td>If the value is _true_, add the command to the element instead of the browser. Default: _false_.</td>
44+
</tr>
45+
46+
</tbody>
3147
</table>
3248

3349
## Usage Examples {#examples}
3450

3551
```javascript
3652
// log the pause duration in ms before the pause and then return the value
37-
await browser.overwriteCommand("pause", function (origPauseFunction, ms) {
53+
await browser.overwriteCommand("pause", async function (origPauseFunction, ms) {
3854
console.log(`Sleeping for ${ms}`);
3955

40-
origPauseFunction(ms);
56+
await origPauseFunction(ms);
4157

4258
return ms;
4359
});

i18n/ru/docusaurus-plugin-content-docs/current/commands/browser/addCommand.mdx

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,43 @@ import Admonition from "@theme/Admonition";
1414
## Использование {#usage}
1515

1616
```javascript
17-
await browser.addCommand(name, callback, elementScope);
17+
browser.addCommand(name, callback, elementScope);
1818
```
1919

2020
## Параметры команды {#parameters}
2121

2222
<table>
23-
<thead>
24-
<tr><td>**Имя**</td><td>**Тип**</td><td>**Описание**</td></tr>
25-
</thead>
26-
<tbody>
27-
<tr><td>name</td><td>String</td><td>Имя кастомной команды.</td></tr>
28-
<tr><td>callback</td><td>Function</td><td>Функция-реализация команды.</td></tr>
29-
<tr><td>elementScope</td><td>Boolean</td><td>Если значение _true_, то добавить команду к элементу, а не к браузеру. По умолчанию: _false_.</td></tr>
30-
31-
</tbody>
23+
<thead>
24+
<tr>
25+
<td>**Имя**</td>
26+
<td>**Тип**</td>
27+
<td>**Описание**</td>
28+
</tr>
29+
</thead>
30+
<tbody>
31+
<tr>
32+
<td>name</td>
33+
<td>String</td>
34+
<td>Имя кастомной команды.</td>
35+
</tr>
36+
<tr>
37+
<td>callback</td>
38+
<td>Function</td>
39+
<td>Функция-реализация команды.</td>
40+
</tr>
41+
<tr>
42+
<td>elementScope</td>
43+
<td>Boolean</td>
44+
<td>Если значение _true_, то добавить команду к элементу, а не к браузеру. По умолчанию: _false_.</td>
45+
</tr>
46+
</tbody>
3247
</table>
3348

3449
## Примеры использования {#examples}
3550

3651
```javascript
3752
// добавляем команду getUrlAndTitle
38-
await browser.addCommand("getUrlAndTitle", async function (customParam) {
53+
browser.addCommand("getUrlAndTitle", async function (customParam) {
3954
return {
4055
url: await this.getUrl(), // `this` здесь и ниже относится к объекту "browser"
4156
title: await this.getTitle(),
@@ -45,14 +60,14 @@ await browser.addCommand("getUrlAndTitle", async function (customParam) {
4560

4661
// используем новую команду getUrlAndTitle
4762
it("should use my add command", async ({ browser }) => {
48-
await browser.url("https://webdriver.io");
63+
await browser.url("https://testplane.io");
4964

5065
const result = await browser.getUrlAndTitle("foobar");
5166

52-
assert.strictEqual(result.url, "https://webdriver.io");
67+
assert.strictEqual(result.url, "https://testplane.io");
5368
assert.strictEqual(
5469
result.title,
55-
"WebdriverIO · Next-gen browser and mobile automation test framework for Node.js",
70+
"Testplane Docs | Testplane Docs",
5671
);
5772
assert.strictEqual(result.customParam, "foobar");
5873
});

i18n/ru/docusaurus-plugin-content-docs/current/commands/browser/overwriteCommand.mdx

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,40 @@ await browser.overwriteCommand(name, callback, elementScope);
1919
## Параметры команды {#parameters}
2020

2121
<table>
22-
<thead>
23-
<tr><td>**Имя**</td><td>**Тип**</td><td>**Описание**</td></tr>
24-
</thead>
25-
<tbody>
26-
<tr><td>name</td><td>String</td><td>Имя кастомной команды.</td></tr>
27-
<tr><td>callback</td><td>Function</td><td>Функция-реализация команды.</td></tr>
28-
<tr><td>elementScope</td><td>Boolean</td><td>Если значение _true_, то добавить команду к элементу, а не к браузеру. По умолчанию: _false_.</td></tr>
29-
30-
</tbody>
22+
<thead>
23+
<tr>
24+
<td>**Имя**</td>
25+
<td>**Тип**</td>
26+
<td>**Описание**</td>
27+
</tr>
28+
</thead>
29+
<tbody>
30+
<tr>
31+
<td>name</td>
32+
<td>String</td>
33+
<td>Имя кастомной команды.</td>
34+
</tr>
35+
<tr>
36+
<td>callback</td>
37+
<td>Function</td>
38+
<td>Функция-реализация команды.</td>
39+
</tr>
40+
<tr>
41+
<td>elementScope</td>
42+
<td>Boolean</td>
43+
<td>Если значение _true_, то добавить команду к элементу, а не к браузеру. По умолчанию: _false_.</td>
44+
</tr>
45+
</tbody>
3146
</table>
3247

3348
## Примеры использования {#examples}
3449

3550
```javascript
3651
// вывести время паузы в мс перед самой паузой и вернуть потом это значение
37-
await browser.overwriteCommand("pause", function (origPauseFunction, ms) {
52+
await browser.overwriteCommand("pause", async function (origPauseFunction, ms) {
3853
console.log(`Sleeping for ${ms}`);
3954

40-
origPauseFunction(ms);
55+
await origPauseFunction(ms);
4156

4257
return ms;
4358
});

0 commit comments

Comments
 (0)