New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

testarmada-magellan-nightwatch

Package Overview
Dependencies
Maintainers
3
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

testarmada-magellan-nightwatch

Nightwatch.js adapter for Magellan

  • 1.4.18
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
3
Weekly downloads
 
Created
Source

magellan-nightwatch

The NightwatchJS adapter for Magellan

Running Tests

For instructions on how to run tests, please see the magellan documentation at: https://github.com/TestArmada/magellan

Writing Tests

Tests are structured as simple modules with a single exported object containing keyed functions. The functions are executed in the order in which they appear in the object source. Each function represents a step in the test, and its key in the test object should represent the name of the step. Each step function gets a client as an argument which represents a browser. For more information on writing tests, see the Nightwatch.js documentation.

  module.exports = {
    "Load homepage": function (client) {
      client
        .url("http://localhost/");
    },

    "Verify header is visible": function (client) {
      client
        .getEl("#header");
    }

    "Reveal help modal": function (client)
      client
        .clickAutomationEl("show-help")
        .getEl("#help-modal")
        .assert.elContainsText("#help-modal", "This is the help modal");
    }
  }

Command Vocabulary

magellan-nightwatch is a wrapper around Nightwatch.js, but is constrained to a limited subset of Nightwatch vocabulary to promote reliability.

Command Equivalent List

If you're familiar with Nightwatch or are looking to translate Nightwatch examples into magellan-nightwatch, refer to the table below for equivalent support commands:

Nightwatch Command / Assertion`magellan-nightwatch` Equivalent
click("[data-automation-id="mybutton"])clickAutomationEl("mybutton")
click(selector)clickEl(selector)
waitForElementPresent or waitForElementVisiblegetEl(selector)
moveToElementmoveToEl(selector, xoffset, yoffset)
setValue(selector, value)setElValue(selector, value)
waitForElementNotPresent(selector)waitForElNotPresent(selector)
waitForElementNotPresent(selector)waitForElNotPresent(selector)
assert.containsText(selector, text)assert.elContainsText(selector, regex or text)
_(no nightwatch equivalent)_assert.elNotContainsText(selector, text)
_(no nightwatch equivalent)_assert.selectorHasLength(selector, expectedLength)
_(no nightwatch equivalent)_assert.elLengthGreaterThan(selector, selectUsing, lengthToCompare)
Custom Commands Examples

The commands included with magellan-nightwatch are safer, more reliable and "thrash-resistent" versions of Nightwatch commands. Note that clickEl(), clickAutomationEl(), and setElValue() are safe to call without first waiting for their selector to appear because they execute getEl() as part of their internals. Consider the following snippet:

  client
    .getEl("#submit_order")
    .clickEl("#submit_order")

The above snippet can be shortened to the following form (and will execute faster):

  client
    .clickEl("#submit_order")

Our custom commands try be as readable and flexible as possible. For example, rather than just accepting text inside the `el(Not?)ContainsText commands, you can also include a regular expression to match text in a much more flexible way

  client
    .elContainsText("#submit_order", "Price \d+\.\d\d")

This would match "Price" followed by one more more digits, a decimal, then two more digits. You can use regexper to help visualize and debug regular expressions

As-is Supported Nightwatch Vocabulary

Some Nightwatch commands and assertions are supported out of the box.

Supported Nightwatch Commands
  • clearValue()
  • pause()
  • attributeEquals()
  • saveScreenshot()
  • setCookie()
  • url()
  • getText()
  • getValue()
Supported Nightwatch Assertions
  • cssClassPresent()
  • cssProperty()
  • elementNotPresent()
  • elementPresent()
  • urlContains()
  • visible()
Custom Commands

magellan-nightwatch supports the development of custom commands to allow the re-use of common parts of tests. If you're using the same snippets of code to fill out a form that appears in many tests, or have a common way to sign into your application, etc, then custom commands are for you. Please see the Nightwatch.js documentation for more on commands.

FAQs

Package last updated on 24 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc