dce-selenium
Version:
Selenium library to simplify testing and automatically snapshot the DOM.
40 lines (28 loc) • 1.31 kB
Markdown
Relevant resources:
[](https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/)
[](https://mochajs.org)
1. Go to `classes/Driver.js` and add a new static function. Do not add a function to the Driver class.
```js
Driver.funcName = async function (param1, param2) {
...
};
```
- On the first line of the function, add `this.log(<description of command>)`
- To print to the console log, use `this.log` (not `console.log`)
- Refer to other functions in Driver using `this.functionName(...)`
- Access the Selenium WebDriver using `this.webdriver`
2. Optional: add snapshots to your command by adding a `snapshotType` to your function
```js
Driver.funcName.snapshotType = {
before: SNAPSHOT_TYPES.SCREENSHOT_AND_SOURCE, <-- optional
during: SNAPSHOT_TYPES.TEXT <or> SNAPSHOT_TYPES.JSON, <-- options
after: SNAPSHOT_TYPES.SCREENSHOT_AND_SOURCE, <-- optional
};
```
Description of each snapshot type:
- JSON – save output of the function as JSON
- SCREENSHOT\_AND\_SOURCE – screenshot & save page src
- TEXT – save output of the function as text