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 🙏

© 2026 – Pkg Stats / Ryan Hefner

selenium-pageobject

v1.2.0-beta

Published

A lightweight pageobject library for selenium's webdriverjs

Readme

selenium-pageobject

A lightweight pageobject library for use with webdriverjs.

Read about pageobjects at Martin Fowler's bliki and Selenium's wiki.

Installation

npm install selenium-pageobject

Getting started

The primary classes are:

  • PageNavigator
  • everything in the elements directory

The PageNavigator provides methods to visit pages etc. The Element and its derived classes are wrappers to elements on the web page.

You can directly use the elements to access things on the page like this:

var wd = require('selenium-webdriver'),
    elements = require('selenium-pageobject').elements;
    
var driver = new wd.Builder().withCapabilities(wd.Capabilities.chrome()).build(),
    pageNavigator = new PageNavigator({ driver: driver });

pageNavigator.visit('http://www.example.com');
var cb = new elements.CheckBox(driver, By.id('checkboxId'));
cb.getChecked().then(function (isChecked) {
    /* do something with isChecked */
});

PageObjects (WIP)

There's no actual class that represents a PageObject, since these are the things you write to drive your site. So let's run through a quick example of what one might look like.

Start with modelling your UI, so mypagemodel.js:

var By = require('selenium-webdriver').By,
    po = require('selenium-pageobject'), extend = po.extend, Element = po.elements.Element;

module.exports = (function (_super) {
    extend(MyPageModel, _super);

    function MyPageModel() {
    	_super.apply(this, arguments);

    	this.username = this.ef.textbox(By.id('username'));
        this.password = this.ef.textbox(By.id('password'));
        this.loginButton = this.ef.element(By.id('login'));
    }

    return MyPageModel;
})(Element);

Now create your PageObject in mypage.js:

var By = require('selenium-webdriver').By,
    MyPageModel = require('./mypagemodel.js');

function MyPage(driver) {
    this._ui = new MyPageModel(driver, By.tagName('html'));
}

MyPage.prototype.login = function (username, password) {
    this._ui.username.setValue(username);
    this._ui.password.setValue(password);
    return this._ui.loginButton.click();
};

module.exports = MyPage;

Now write your test in mypageTests.js:

var chai = require('chai'), expect = chai.expect,
    wd = require('selenium-webdriver'), By = wd.By,
    PageNavigator = require('selenium-pageobject').PageNavigator,
    MyPage = require('./mypage.js');

describe("MyPage", function() {
    var driver;
    var url = 'file://' + __dirname + '\\mypage.html';

    before(function() {
        driver = new wd.Builder().withCapabilities(wd.Capabilities.chrome()).build();
    });

    beforeEach(function() {
        driver.get(url);
    });

	it("can login", function(done) {
        var pageNavigator = new PageNavigator({ driver: driver });
        var myPage = new MyPage(driver);

        pageNavigator.visit(url).then(function () {
            myPage.login('JohnSmith', 'password').then(function () {
                // expect something
            });
        }).then(function () {
            done();
        }).then(null, function (err) {
            done(err);
        });
    });

    after(function(done) {
        driver.quit().then(done);
    });
});

Workflows

This is an experimental feature at the moment and may not make it into the final version

A Workflow allows you to define a set of steps which it will then run through, you can define callbacks that occur on specific steps of the workflow.