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

v0.1.0

Published

Execute test written in test case

Downloads

3

Readme

Features

  • Run plain English test case as a test
  • Built-in chromedriver, firefox driver, and reporter
  • No need to run a selenium-server standalone jar file
  • Ability to control execution speed
  • Angular2-Friendly without Protractor

Install

  • npm install webdriver-tt

Usage

  • node_modules/webdriver-tt/bin my-test-case.txt

Test Case File Example

My Test Scenario
  My Test Case
    open /login
    enter 'John' into 'username'
    enter 'secret' into 'password'
    see 'successful'

Selenuim WebDriver is great! .......... But, it's not that easy for a beginner who does not understand full concept of Promise used in there.

For example, the following test code does make sense, but it will only work if you are super lucky;

var webdriver = require('selenium-webdriver'),
    until = webdriver.until;

var driver = new webdriver.Builder().forBrowser('firefox').build();

driver.get('https://run.plnkr.co/plunks/aWTZswhBnUVLg7qyDr83/');
driver.findElement({css:'input'}).then(function(element) {
  element.sendKeys('Cheese!');
  element.getAttribute('value').then(function(str) {
    console.log('str', str); 
  });
});;

driver.quit();

You may get this error very easily, NoSuchElementError: Unable to locate element.

/Users/allen/github/webdriver-tt/node_modules/selenium-webdriver/lib/promise.js:654
    throw error;
    ^

NoSuchElementError: Unable to locate element: {"method":"css selector","selector":"input"}

The reason is not only about timeout, but also every about implicit wait instruction is not executed insequence.

This pain grows when we deal with Angular, especially Angular2. That might be the reason protractor is invented. However, even with protractor, timeout error, implicit and explicit wait still comes time to time, makes successful tests very inconsistent.

WebDriver has very nice feature of wait/until to resolve things before to go further tests. We can change it to use explicit wait by using driver.wait and webdriver.until, but almost all hates to deal with chainging these properly, and even properly chained code is not so maintainable.

wait syntax

driver.wait(CONDITION, MS);

We can combine this syntax with driver.until. conditions. For example,

driver.until.elementIsVisible({css: '.my-class'})

The problem is that we can do only once. The following code is not guranteed to run in sequence

driver.wait(CONDITION1, 2000).then(function() { console.log(1) });
driver.wait(CONDITION2, 2000).then(function() { console.log(2) });
driver.wait(CONDITION3, 2000).then(function() { console.log(3) });

To make it really sequenctial, we need to code like the following

driver.get('http://www.primefaces.org/primeng/#/autocomplete');

driver.wait(until.elementLocated({css:"h3.first"}), 20000).then(function() {
 console.log(1);
}).then(function() {
  driver.wait(until.elementLocated({css:"div"}), 20000).then(function() {
   console.log(2);
 })
}).then(function() {
  driver.wait(until.elementLocated({css:"body"}), 20000).then(function() {
   console.log(3);
 })
})

Although the above code works, the repeativive function(), then, and { ..} makes people not to focus on test, but the Javascript promise syntax.

webdriver-tt is designed to focus on test cases, not Javascript syntax by genrating promise-chained then..then..then..then..then.. code from clean test cases.

These are pattern of commands

  • open browser {{URL}}
  • visit {{URL}}
  • find {{ELEMENT}}
  • enter {{STRING}} into {{ELEMENT}}
  • click {{ELEMENT}}
  • wait until alert is present
  • wait until {{ELEMENT}} present
  • wait until {{ELEMENT}} is (not) visible
  • wait until {{ELEMENT}} is (en|dis)abled
  • wait until {{ELEMENT}} is (not) selected