This package contains standard objects for TestX.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.npmignore
LICENSE
README.md
index.js
package-lock.json
package.json
tests.js

README.md

TestX Standard objects

This package contains standard objects for testx. These object locators come from Protractor.

Installation

Install the package with:

npm install @testx/objects-standard --save

Usage

In your object files

const { xpath, css } = require('@testx/objects-standard');

module.exports = {
  "MyObject": xpath("//input"),
  "MyOtherObject": css(".cool-class")
}

And then in your testx script:

- go to:
    url: /
- set:
    MyObject: some stuff
    MyOtherObject: other things

Directly in your testx scripts

Add to your tests like any other testx node module. In your config file, as part of the onPrepare function:

testx.objects.add(require('@testx/objects-standard'))

Then use these as any other (functional) object reference:

- go to:
    url: /
- set:
    linkText('Login'):
    name('username'): testuser
    name('password'): verysecret
    buttonText('Login'):

NOTE: Avoid using it this way too often or you may end up with fragile set of tests.

Available objects

This package exposes almost all non-angular protractor (web driver++) element locators. It also adds some custom ones.

Object reference Description
css Locates elements using a CSS selector.
xpath Locates elements matching a XPath selector.
id Locates an element by its ID.
name Locates elements whose name attribute has the given value.
linkText Locates link elements whose visible text matches the given string.
partialLinkText Locates link elements whose visible text contains the given substring.
className Locates elements that have a specific class name.
tagName Locates elements with a given tag name.
buttonText Find a button by text.
partialButtonText Find a button by partial text.
cssContainingText Find elements by CSS which contain a certain string.