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

webdriver-helper

v0.2.1

Published

JavaScript WebDriver Helper offer the friendly apis while using selenium-webdriver.

Downloads

3

Readme

webdriver-helper

This helper library offer lots of friendly api while using JavaScript WebDriver

Getting Started

Install the module with: npm install webdriver-helper to enable the friendly APIs.

Documentation

You could setup the selenium webdriver like this. Remember to require 'webdriver-helper' to enable friendly apis.

var webdriver = require('selenium-webdriver');
require('chai').should();
// enable the friendly apis by requiring 'webdriver-helper'
require('webdriver-helper'); 

var builder = new webdriver.Builder().
  usingServer('http://localhost:4444/wd/hub').
  withCapabilities({
    browserName: 'firefox' 
  });
var browser = builder.build();
browser.get('http://localhost:9001');

Browser API

browser.navigateTo(path)

Go to the path which is relative to current path.

browser.navigateTo('/demo.html?a=1&b=2#c=1');
browser.currentUrl(function(currUrl, url) {
  currUrl.should.equal('http://localhost:9001/demo.html?a=1&b=2#c=1')
});

browser.currentUrl(currHandler)

Get current url.

browser.navigateTo('/demo.html?a=1&b=2#c=1');
browser.currentUrl(function(currUrl, url) {
  currUrl.should.equal('http://localhost:9001/demo.html?a=1&b=2#c=1');
  url.protocol.should.equal('http:');
  url.slashes.should.equal(true);
  url.host.should.equal('localhost:9001');
  url.port.should.equal('9001');
  url.hostname.should.equal('localhost');
  url.href.should.equal('http://localhost:9001/demo.html?a=1&b=2#c=1');
  url.hash.should.equal('#c=1');
  url.search.should.equal('?a=1&b=2');
  url.query.should.equal('a=1&b=2');
  url.pathname.should.equal('/demo.html');
  url.path.should.equal('/demo.html?a=1&b=2');
});

browser.refresh()

Refresh current page.

browser.forward()

Go forward to next page in history.

browser.back()

Go back to privious page in history.

browser.title(titleHandler)

Get title in current page.

browser.title(function (title) {
  title.should.equal('your title');
});

Window API

browser.window()

Get current window.

browser.window().position(positionHandler)

Get current window's position.

browser.window().position(function (x, y) {
  x.should.equal(0);
  y.should.equal(0);
});

browser.window().position(x, y)

Set current window's position to (x, y) relative to screen.

browser.window().position(100, 100);

browser.window().size(sizeHandler)

Get current window's size.

browser.window().size(function (width, height) {
  width.should.equal(500);
  height.should.equal(500);
});

browser.window().size(width, height)

Set current window's size with width and height.

browser.window().size(500, 500)

browser.window().maximize()

Maximize the current window to full screen.

Elements API

browser.elements(selector)

Get all matched element by selector. every element could use the friendly api listed below.

browser.elements(selector).count(coundHandler)

Get count of all matched elements.

browser.elements('input').count(function (count) {
  count.should.equal(6);
});

browser.elements(selector).get(index, elemHandler)

Get the element in matched elements according to index.

browser.elements('input').get(0, function (elem) {
  elem.enter('hello world!');
  // elem.click();
});

browser.elements(selector).initialized

Get the status that all elements is initialized or not.

browser.elements(selector).init(initedHandler)

Initialize all elements and save inside. In initedHandler, initialized property will be updated to true. And you could change asyn-invoking to sync-invoking. For example,

browser.elements('input').init(function (elems) {
  this.initialized.should.be.true;
  this.count().should.equal(6);
  this.get(0).enter('hello world');
  this.get(1).attr('name').should.equal('textbox');
  /\* ... \*/
});

browser.element(selector)

Get first matched element by selector.

browser.element(selector).click()

Click the element, the click method is also used for browser.input(), browser.dropdownlist() and browser.link() element.

browser.element(selector).value(valueHandler)

Get value for the the matched element's value attribute. It could used in browser.input(selector).value() as well.

browser.element('input#name').value(function (val) {
  val.should.equal('your name');
});

browser.element(selector).attr(attrName, attrHandler)

Get value of the matched element's attrubute with attribute name attrName.

browser.element('input[name="textbox"]').attr('name', function (attr) {
  attr.should.equal('textbox');
});

browser.element(selector).css(propertyName, valueHandler)

Get css value of the matched element's css property with name propertyName.

browser.element('input[name="textbox"]').css('font-family', function (property) {
  property.should.equal('Georgia');
});

browser.element(selector).text(textHandler)

Get the innerText of the matched element.

browser.element('body').text(function (text) {
  text.should.contain('hello world!');
});

browser.element(selector).html(htmlHandler)

Get the innerHTML of the matched element.

browser.element('body').html(function (html) {
  html.should.contain('<p>hello world!</p>');
});

browser.element(selector).isEnabled(enabledHandler)

Get value for the matched element's status.

browser.element('input#btn').isEnabled(function (enabledStatus) {
  enabledStatus.should.be.false;
});

browser.input(selector)

Get first matched input element by selector, it includes textbox, checkbox, radio etc...

browser.input(selector).enter(text)

Enter text into matched textbox.

browser.input(selector).value(valueHandler)

Get value of matched textbox

browser.input(selector).check()

Check matched checkbox.

browser.input(selector).uncheck()

Uncheck matched checkbox.

browser.input(selector).isChecked(checkedHandler)

Get the checked status.

browser.input('input#checkbox').isChecked(function (checked) {
  checked.should.be.true;
})

browser.input(selector).select()

Select matched radio button.

browser.input(selector).isSeleced(selectedHandler)

Get the selected status. Same as isChecked.

browser.dropdownlist(selector)

Get first matched select element by selector.

browser.dropdownlist(selector).option(val1/*, val2 ... */)

Select these options with the valus in arguments. If the dropdownlist couldn't be multi-selected, the option with the last value would be selected.

browser.dropdownlist(selector).value(valueHandler)

Get the value for matched dropdownlist.

browser.dropdownlist(selector).values(valuesHandler)

For the multi-selected dropdownlist, it will return array of values.

browser.dropdownlist(selector).values(function (values) {
  values.should.eql([2, 3]);
});

browser.link(selector)

Use css selector to find the matched link

browser.link(partialLinkText)

ONLY FOR LINK

browser.link(':contains("Partial Link Text")').click()

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

0.1.0 2013-10-17 MVP

License

Copyright (c) 2013 Wang Qiu
Licensed under the MIT license.