Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ghoshasish99/webdriverio-mocha
Testing with WebdriverIO and Mocha
https://github.com/ghoshasish99/webdriverio-mocha
mocha testautomation webdriverio
Last synced: about 1 month ago
JSON representation
Testing with WebdriverIO and Mocha
- Host: GitHub
- URL: https://github.com/ghoshasish99/webdriverio-mocha
- Owner: ghoshasish99
- Created: 2020-01-31T14:39:31.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-06-25T20:26:45.000Z (over 2 years ago)
- Last Synced: 2023-03-06T15:51:18.289Z (almost 2 years ago)
- Topics: mocha, testautomation, webdriverio
- Language: JavaScript
- Homepage:
- Size: 28.9 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WebdriverIO with Mocha
[![Build Status](https://dev.azure.com/AutomationsTools/Execution/_apis/build/status/ghoshasish99.WebdriverIO-Mocha?branchName=master)](https://dev.azure.com/AutomationsTools/Execution/_build/latest?definitionId=3&branchName=master)
### Getting Started
* Create a standard node project using `npm init` and following the next steps
* To install WebdriverIO, run this command on commandline `npm i --save-dev @wdio/cli`
* To Generate the WebdriverIO configuration file, run this command `npx wdio config -y`. This will create all config parameters and download subsequent libraries.### Writing tests
By default WebdriverIO uses `mocha` framework. So you can write your code in `describe` & `it` blocks, like so :
```javascript
describe('Login and Registration', () => {
it('login should fail with invalid credentials', () => {
browser.url('http://awswrkshpalb-1570520390.us-west-2.elb.amazonaws.com:3000/cts-shop/login')
$('#email').setValue('username');
$('#password').setValue('wrongpassword');
$('form.login > .MuiButtonBase-root > .MuiButton-label').click();
expect($('=Wrong username/password')).toBeVisible();
});
});
```
By default, WebdriverIO globally exposes `browser`.Most common types of WebdriverIO selectors are as follows :
```javascript
$('h2.subheading a') //CSS selector
$('=WebdriverIO') //Link Text
$('//body/p[2]') //Xpath
```
To execute WebdriverIO tests, simply use `npx wdio wdio.conf.js`To run WebdriverIO test in headless mode, add the following capability inside the wdio.conf.js file :
```javascript
'goog:chromeOptions': {
args: ['--headless'],
}
```
To know more about WebdriverIO, visit the [official page.](https://webdriver.io/)