npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

protractor-pageobject

v0.0.1

Published

Page object pattern implementation for protractor and webdriverjs.

Downloads

3

Readme

Protractor Page Object

Protractor Page Object pattern for Protractor.

Features

  • encapsulate your page or components interactions and selectors in classes
  • allows to abstract elements and components in your tested page, which facilitate refactoring when changing the html structure.
  • allows to easily set input fields

Installation

# not published to npm yet...
npm install --save-dev protractor-pageobject

Examples

check the examples folder.

For more examples, you can also check the pages and components created for integration tests.

API

Base

This is the Page and Component parent class.

els

A map of element selectors, which defines the elements you want to interact with. Used to retrieve elements or components without having to specify a selector. Check base.element(elName), base.elements(elName) and base.component(elName).

els: {
  'searchBox': by.name('q')
}

comps

A map of component classes. Each key should have a corresponding key in els map.

comps: {
  searchBox: require('./path/to/component-subclass'),  // short version
  anotherComponent: {
    model: require('./path/to/another-component-subclass'),
    opts: {opt1: 'val1'}
  }
}

element(elName)

Returns a protractor element. elName should be key in the els map.

elements(elName)

Returns a protractor elements (array). elName should be a key in the els map.

components(elName)

Returns a protractor-pageobject Component instance. elNameshould be a key in theels` map.

isElementPresent(elName)

Returns a promise which resolves to a boolean value.

setFieldValue(elName, value)

Sets the value of a field. It will use the following rules (in the specified order):

  • If elName is a key in comps and this component has a method setValue, then it will call that method.

  • If the Page or Component instance has a setElName. using camelCase. For example, if elName = 'my-el-1', then the method should be called setMyEl1`

  • If none of the above works, then it will detect the field type and use the proper selenium command to set the value (sendKeys(), click() on dropdown or checkboxes...). Here is the list of supported fields for now:

    • input[type=email]
    • input[type=file]
    • input[type=number]
    • input[type=password]
    • input[type=search]
    • input[type=tel]
    • input[type=text]
    • input[type=textarea]
    • input[type=url]
    • input[type=checkbox]
    • input[type=radio]
    • select (regular or mutli)

setFields(opts)

Sets multiple fields at the same time, using setFieldValue(elName, value). Each key should be present in els map.

myComponent.setFields({
  elName1: 'value1',
  elName2: 'value2',
  ...
});

Page

Page inherits from Base so all Base methods and properties are inherited. Here is the list of additional methods.

url

A property or a method that is used to navigate using the get() method below.

get()

Navigate to the url property.

title()

returns a promise that will resolve with the current page title (usually the <title> tag in <head>). Alias of browser.getTitle().

getCurrentUrl()

returns a promise that will resolve with the current page title. Alias of `browser.getCurrentUrl()

Component

Like Page, Component inherits from Base so all Base methods and properties are inherited.

new Component(opts)

When creating a new instance of a component, you need to at least provide one property called el which should be a protractor ElementFinder.

ItemList

TODO

License

MIT.