plus.tester
v0.1.5
Published
plus tester
Downloads
1
Readme
plus.tester
npm install plus.tester --save-dev
npm install selenium-webdriver chromedriver --save-dev
How to use
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
# features/google.feature
Feature: Example feature
Scenario: Google
Given I open google
Then I see search line
Then I click Lucky button
/// 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"]`);
});
});
// 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)
});
// 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
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))