0.0.1 • Published 6 years ago

protractor-elements v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

protractor-elements

Enabling abstraction levels in your Protractor tests.

Status

Known Vulnerabilities

Install

From npm via npm or yarn package managers.

npm install protractor-elements
yarn add protractor-elements

Motivation

Your test should NOT read like this:

describe(`homepage`, () => {
  it(`should greet the named user`, () => {
    browser.get(`http://www.my-demo.site`);

    element(by.model(`yourName`)).sendKeys(`Igor`);

    const greeting = element(by.binding(`yourName`));
    expect(greeting.getText()).toEqual(`Hi, Igor!`);
  });
});

but rather

describe(`homepage`, () => {
  it(`should greet the named user`, async () => {
    await new Site(`http://www.my-demo.site`).navigateTo();

    const nameInput = new InputText(element(by.css(`.yourName`)));
    await nameInput.setDisplayValue$(`Igor`);

    const greetingDivElement = new Element(element(by.css(`.greeting`)));
    expect(await greetingDivElement.getDisplayValue$()).toEqual(`Hi, Igor!`);
  });
});

because the wrappers like InputText or Element allow better type safety; simplify PageObject and ComponentObject creation; and improve code maintainabiiity.

License

This code is distributed under MIT license.