1.1.0 • Published 6 years ago

@testx/objects-standard v1.1.0

Weekly downloads
8
License
GPLv3
Repository
-
Last release
6 years ago

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 referenceDescription
cssLocates elements using a CSS selector.
xpathLocates elements matching a XPath selector.
idLocates an element by its ID.
nameLocates elements whose name attribute has the given value.
linkTextLocates link elements whose visible text matches the given string.
partialLinkTextLocates link elements whose visible text contains the given substring.
classNameLocates elements that have a specific class name.
tagNameLocates elements with a given tag name.
buttonTextFind a button by text.
partialButtonTextFind a button by partial text.
cssContainingTextFind elements by CSS which contain a certain string.
deepCssFind an element by css selector within the Shadow DOM.
1.1.0

6 years ago

1.0.1

7 years ago

1.0.0

7 years ago