Skip to content

ktsalik/ultronjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm npm

UltronJS

Ultron is a JavaScript/NodeJS library for creating automated tests running on the browser of your choice.

Example

var Ultron = require('ultronjs');
var ultron = new Ultron('chrome'); // open Chrome

ultron
  .it("should open GitHub via Google")
  .describe(function() {

    this.open('http://google.com');

    this.wait('input[type="text"]').toAppear();

    this.fill('input[type="text"]').with('GitHub');

    this.$('input[type="text"]').submit();

    this.wait('#ires').toAppear(); // results container

    this.click('#ires a[href="https://github.com/"]'); // first result

    this.wait.until.titleContains('GitHub');

    this.wait.for(1000); // wait for just a sec

  })
  .run()
  .then(function() {
    ultron.end(); // close browser
  });

Installation

Using npm

$ npm install ultronjs

# or

$ npm i -D ultronjs

You also need to download and include in your PATH the driver of the browser of your choice in order to use Ultron.

Drivers downloads

API Reference

Table of Contents

Open

Test.open(url)

  • url {string} - The url to open in the browser.
Example
new require('ultronjs')
  .it("Should open GitHub")
  .describe(function() {

    this.open('http://github.com');

  })

Wait

Test.wait(selector)

  • selector {string} - CSS selector of the target element.
methods

toAppear() - Waits until the element appears.

Example
new require('ultronjs')
  .it("Should wait for the search input")
  .describe(function() {

    this.wait('#search-input').toAppear();

  })

until.titleIs(text) - Waits until the title matches the given text.

Example
new require('ultronjs')
  .it("Should wait until the page title contains the word GitHub")
  .describe(function() {

    this.wait.until.titleIs('GitHub');

  })

until.titleContains(text) - Waits until the title of the page contains the given text.

Example
new require('ultronjs')
  .it("Should wait until the page title is GitHub")
  .describe(function() {

    this.wait.until.titleContains('GitHub');

  })

for(milliseconds) - Waits for the given time in milliseconds.

Example
new require('ultronjs')
  .it("Should wait for 2 seconds")
  .describe(function() {

    this.wait.for(2000);

  })

Fill

Test.fill(selector)

  • selector {string} - CSS selector of the target element.
methods

with(text)

Example
new require('ultronjs')
  .it("Should fill GitHub search input with `UltronJS`")
  .describe(function() {

    this.fill('input[name="q"]').with('UltronJS');

  })

Click

Test.Click(selector)

  • selector {string} - CSS selector of the target element.
Example
new require('ultronjs')
  .it("Should click link to GitHub")
  .describe(function() {

    this.click('#ires a[href="https://github.com/"]');

  })

Page

Test.page.title

methods

should.contain(text)

  • text {string}
Example
new require('ultronjs')
  .it("Should find the word GitHub in page's title")
  .describe(function() {

    this.page.title.should.contain('GitHub');

  })

findElement.by.linkText(text)

  • text {string}
methods

click()

Example
new require('ultronjs')
  .it("Should find and click the link of UltronJS repository")
  .describe(function() {

    this.page.findElement.by.linkText('masterakos/ultronjs').click();

  })

$

Test.$(selector)

  • selector {string} - Css selector of the target element.
methods

submit()

Example
new require('ultronjs')
  .it("Should submit the search form")
  .describe(function() {

    // submit by selecting the form
    this.$('form').submit();
    // or by selecting an input inside the form
    this.$('input[name="q"]').submit();
    // or by selecting the submit button
    this.$('button[type="submit"]').submit();

  })

should

methods

count(number)

Example
new require('ultronjs')
  .it("Should find 4 links to the page")
  .describe(function() {

    this.$('a').should.count(4);

  })

haveContent(text)

Example
new require('ultronjs')
  .it("Should find the right content in body element")
  .describe(function() {

    this.$('body').should.haveContent(`Browser Automated Testing library`);

  })

About

A JavaScript/NodeJS Browser Automated Testing library based on Selenium webdriver

Resources

Stars

Watchers

Forks

Packages

No packages published