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-factory

v0.0.1

Published

node-selenium configuration wrapper

Readme

node-selenium-factory

What's this

WebDriverのテストを Node + wd-sync で書く際のinstance factoryです。 Serverの接続先やブラウザを、SauceLabs互換の環境変数もしくはコマンドライン引数から設定して切り替えできるようになります。

WebDriverのテストの実行するのに、簡単にターゲットを切り替えたいと思いませんか?
接続先をローカルのターゲット or 共有サーバ or SauceLabs と切り替えるのにテストコードを修正したくないですよねー。
このfactoryを使って、接続先やターゲットブラウザ等をラップして、切り替えられるようにしましょうぜ!(●^o^●)

How to use

(a) 環境変数で指定する場合

  • SELENIUM_HOST
    • Remote WebDriver ServerのIPアドレス
  • SELENIUM_PORT
    • Remote WebDriver Serverのポート番号
  • SELENIUM_BROWSER
    • ターゲットのブラウザ名
  • SELENIUM_PLATFORM
    • ターゲットのプラットフォーム
  • SELENIUM_VERSION
    • ターゲットのプラットフォームのバージョン番号
  • [option] SELENIUM_COOKIE
    • デフォルトで設定するCookie。name=valueをセミコロン(;)で区切った文字列
  • [option] SELENIUM_LOCAL_STORAGE
    • デフォルトで設定するlocalStorage。name=valueをセミコロン(;)で区切った文字列

example

$ export SELENIUM_HOST="192.168.11.130"
$ export SELENIUM_PORT=8080
$ export SELENIUM_BROWSER="android"
$ export SELENIUM_PLATFORM="ANDROID"
$ export SELENIUM_VERSION="2.3"
$ export SELENIUM_COOKIE="uuid=kjfa09ir3uqrkrwjeaiofuewkl;keyword=tabasa;"
$ export SELENIUM_LOCAL_STORAGE="isTutorialCompleted=true"

$ node ./test/test-code.js

(b) コマンドライン引数で指定する場合

  • --server
    • Remote WebDriver ServerのIPアドレス
  • --port
    • Remote WebDriver Serverのポート番号
  • --browserName
    • ターゲットのブラウザ名
  • --platform
    • ターゲットのプラットフォーム
  • --version
    • ターゲットのプラットフォームのバージョン番号
  • [option] --cookie
    • デフォルトで設定するCookie。name=valueをセミコロン(;)で区切った文字列
  • [option] --localStorage
    • デフォルトで設定するlocalStorage。name=valueをセミコロン(;)で区切った文字列

example

$ node ./test/test-code.js\
    --server 192.168.11.130\
    --port 8080\
    --browserName android\
    --platform "ANDROID"\
    --version "2.3"\
    --cookie "uuid=kjfa09ir3uqrkrwjeaiofuewkl;keyword=tabasa;"\
    --localStorage "isTutorialCompleted=true"\

sample

var factory = require('selenium-factory');

var client  = factory.createRemoteWebDriver(),
    browser = client.browser,
    sync    = client.sync;

sync(function() {

	// 環境変数 or 実行時引数から設定を読み取ってブラウザを初期化
    browser.init(factory.defaultCapabilities());

	// CookieやLocalStorageを保存するため、いったんページを開く
    browser.get("http://example.com/");

	// テスト実行時に常時必要なCookieを設定
    factory.defaultCookieList().forEach(function(cookie) {
        browser.setCookie(cookie);
    });

	// テスト実行時に常時必要なLocalStorageを設定
    factory.defaultLocalStorageList().forEach(function(storage) {
        browser.setLocalStorage(storage);
    });

	// 改めてページを開く
    browser.get("http://example.com/");

	~~~テストコード~~~

    browser.quit();
});