protractor-elements
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

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.

Package Sidebar

Install

npm i protractor-elements

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

47.3 kB

Total Files

45

Last publish

Collaborators

  • another-guy