Skip to content

testxio/standard-objects

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.
deepCss Find an element by css selector within the Shadow DOM.