0.1.5 • Published 7 years ago

plus.tester v0.1.5

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

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

WebTester

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))
0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago