https://github.com/slavahatnuke/plus.tester
https://github.com/slavahatnuke/plus.tester
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/slavahatnuke/plus.tester
- Owner: slavahatnuke
- Created: 2017-03-15T09:30:20.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-13T14:36:01.000Z (almost 8 years ago)
- Last Synced: 2025-03-04T01:08:46.051Z (3 months ago)
- Language: JavaScript
- Size: 228 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## plus.tester
- `npm install plus.tester --save-dev`
- `npm install selenium-webdriver chromedriver --save-dev`### How to use
```javascript
const seleniumWebdriver = require('selenium-webdriver');
const { WebTester } = require('plus.tester');let tester = new WebTester(() => new seleniumWebdriver.Builder().forBrowser('chrome').build());
tester.getDriver()
.then((driver) => driver.manage().timeouts().pageLoadTimeout(30 * 1000));
```### Examples with cucumber.js
```gherkin# features/google.feature
Feature: Example feature
Scenario: Google
Given I open google
Then I see search line
Then I click Lucky button
``````javascript
/// features/step_definitions/google.js
let {defineSupportCode} = require('cucumber');defineSupportCode(function({Given, When, Then}) {
Given('I open google', function () {
return this.iVisit('http://google.com');
});Then('I see search line', function () {
return this.iSee('input');
});Then('I type {stringInDoubleQuotes}', function (stringInDoubleQuotes) {
return this.iType('input', stringInDoubleQuotes);
});Then('I click Lucky button', function () {
return this.iClick(`input[name="btnI"]`);
});});
``````javascript
// features/support/world.js
const {defineSupportCode} = require('cucumber');function CustomWorld() {
let {WebTester} = require('plus.tester');const seleniumWebdriver = require('selenium-webdriver');
this.tester = new WebTester(() => new seleniumWebdriver.Builder().forBrowser('chrome').build());
this.tester.setup({ waitTimeout: 20 * 1000});this.tester.getDriver()
.then((driver) => driver.manage().timeouts().pageLoadTimeout(30 * 1000));this.tester.applyTo(this);
}defineSupportCode(({setWorldConstructor, setDefaultTimeout}) => {
setDefaultTimeout(60 * 1000);
setWorldConstructor(CustomWorld)
});
``````javascript
// features/step_definitions/hooks.js
let {defineSupportCode} = require('cucumber');defineSupportCode(function({After}) {
After(function() {
return this.tester.stop();
});
});
```### WebTester Api
## plus.tester - cheerio
- `npm i cheerio request-promise --save-dev`### How to use
In same way
```javascript
const { WebTesterCheerio } = require('plus.tester');
const tester = new WebTesterCheerio();tester.iOpen('http://plus1generation.com/')
.then(() => tester.iSee('div'))
.then(() => tester.iFindAttribute('*', 'innerText'))
.then((texts) => console.log(texts))
.then(() => tester.iFindAttribute('*[href]', 'href'))
.then((links) => console.log(links))
```