Skip to content

Commit

Permalink
Update CustomCommands.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jayrepo committed Mar 21, 2022
1 parent 4eb1377 commit 2b033ee
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions website/docs/CustomCommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ console.log(typeof browser.myCustomElementCommand2) // outputs "undefined"
console.log(elem3.myCustomElementCommand2('foobar')) // outputs "function"
```

__Note:__ If you need to chain a custom command, the command should end with `$`,
```js
browser.addCommand("user$", (locator) => { return ele })
browser.addCommand("user$", (locator) => { return ele }, true)
await browser.user$('foo').user$('bar').click()
```

Be careful to not overload the `browser` scope with too many custom commands.

We recommend defining custom logic in [page objects](PageObjects.md), so they are bound to a specific page.
Expand Down

0 comments on commit 2b033ee

Please sign in to comment.