0.27.1-32953867.0 • Published 4 years ago

@squiz/mercury-wdio v0.27.1-32953867.0

Weekly downloads
1,497
License
SEE LICENSE IN LI...
Repository
-
Last release
4 years ago

@squiz/mercury-wdio

A set of helper functions and reusable Cucumber definitions. This is intended for internal Squiz usage.

This library was generated with NX. However it uses a forked builder to generate a functional NPM library to work for the purpose of Cucumber Webdriver testing.

Install

Install with your favourite package manager

npm install @squiz/mercury-wdio

In order to use the predefined Step definitions, import the lib where you use Cucumber steps.

import "@squiz/mercury-wdio";

Or in your wdio.config file:

    cucumberOpts: {
        require: [
            "@squiz/mercury-wdio",
        ],
    },

(This could require a direct reference to the file ./node_modules/@squiz/mercury-wdio/wdio.js)

Use helpers

The Mercury WDIO library contains a number of helpers such as Actions, which you can import as such:

import { waitForDisplayed } from '@squiz/mercury-wdio';

Check out the Mercury repo to see the current list, but right now it includes:

clearInputField
clickElement
moveToElement
setInputField
setWindowSize
switchToggle
pause
waitForClickable
waitForDisplayed
waitForEnabled
closeWindow
reloadWindow

checkIfElementContainsText
checkIfElementContainsElement
checkIfElementExists
checkIfElementHasClass
checkElementToggleState

BasePage

Reusing a step as part of a new step

The lib also contains a number of steps, which can be useful when writing your own steps.

You can import a Step itself

import { ManipulationSteps } from '@squiz/mercury-wdio';

Then trigger a step from within your own step! (Simplified example)

@binding()
export class SignOutSteps {
  @given(/^the user clicks on the (user menu)$/, undefined, 20000)
  public async theUserClicksOnTheUserMenu(menu: string): Promise<void> {
    const ENV_VARIABLE_FOO = `root`;
    await ManipulationStepsInstance.theUserClicksOnTheElementLabelled(
      `*[contains(concat(' ',normalize-space(@class),' '),' nav-link ')]`,
      `containing the label`,
      ENV_VARIABLE_FOO,
    );
  }
}

The important part being ManipulationStepsInstance.theUserClicksOnTheElementLabelled where we reference the existing step in order to avoid writing the logic which locates an element and clicks it. This way we only need to define the thing we need to find.

When doing this you need to provide the strings which are expected to come out of the regex statement in the step you're referencing, here we provide containing the label which then triggers something in the function.

We could abstract this into a function which accepts clearer parameters and have the steps themselves only translate text to function, but if we want to explicitly call the step this is how to do it. This also works in order to reference any steps you define yourself!

0.30.0

4 years ago

0.29.0

4 years ago

0.28.0

4 years ago

0.27.0

4 years ago

0.26.0

4 years ago

0.25.1-8801665.0

4 years ago

0.25.0

5 years ago

0.24.0

5 years ago

0.23.0

5 years ago

0.22.0

5 years ago

0.21.0

5 years ago

0.20.0

5 years ago

0.19.0

5 years ago

1.7.1-c8e4e02d.0

5 years ago

1.7.1-b3759740.1

5 years ago

1.7.1-b3759740.0

5 years ago

1.7.1-16395e6a.1

5 years ago

1.7.1-16395e6a.0

5 years ago

1.7.1-bce0a412.0

5 years ago

1.7.1-0368ef4a.0

5 years ago

1.7.1-b1f12580.0

5 years ago

1.7.1-87e98df6.0

5 years ago

1.7.1-039e425e.0

5 years ago

1.7.1-07ce5646.0

5 years ago

1.7.1-07ce5646.1

5 years ago

0.18.32

5 years ago

0.18.31

5 years ago

0.18.30

5 years ago

0.18.29

5 years ago

0.18.28

5 years ago

0.18.27

5 years ago

0.18.26

5 years ago

0.18.24

5 years ago

0.18.25

5 years ago

0.18.23

5 years ago

0.18.22

5 years ago

0.18.21

5 years ago

0.18.20

5 years ago

0.18.19

5 years ago

0.18.18

5 years ago

0.18.17

5 years ago

0.18.15

5 years ago

0.18.16

5 years ago

0.18.14

5 years ago

0.18.10

5 years ago

0.18.13

5 years ago

0.18.7

5 years ago

0.18.6

5 years ago

0.18.5

5 years ago

0.18.4

5 years ago

0.18.2

5 years ago

0.18.3

5 years ago

0.18.0

5 years ago

0.17.1

5 years ago

0.17.0

5 years ago

0.16.5

5 years ago

0.16.4

5 years ago

0.16.3

5 years ago

0.16.2

5 years ago

0.16.1

5 years ago

0.16.0

5 years ago

0.15.14

5 years ago

0.15.4

5 years ago

0.15.13

5 years ago

0.15.12

5 years ago

0.15.11

5 years ago

0.15.10

5 years ago

0.15.4-301a8ac.0

5 years ago

0.15.9

5 years ago

0.15.8

5 years ago

0.15.7-fc023ae.0

5 years ago

0.15.6-940e4db.0

5 years ago

0.15.3-9fb3eb2.0

5 years ago

0.15.3

5 years ago

0.15.3-1b3ab96.0

5 years ago

0.15.2

5 years ago

0.15.2-0a75c77.0

5 years ago

0.15.3-a744dc0.0

5 years ago

0.15.2-43b5102.0

5 years ago

0.15.2-3f5bd65.0

5 years ago

0.15.1-2ab7958.0

5 years ago

0.15.0

5 years ago

0.15.1

5 years ago

0.14.2-cc30614.1

5 years ago

0.14.2-cc30614.0

5 years ago

0.14.2-3364f65.0

5 years ago

0.14.1

5 years ago

0.14.0

5 years ago

0.13.0

5 years ago

0.7.13-7ab6ec2.0

5 years ago

0.8.1-b1468db.0

5 years ago

0.7.14-dce3350.0

5 years ago

0.8.1-a7ce9c2.0

5 years ago

0.8.1-e96d717.0

5 years ago

0.7.1-cafbcd4.0

5 years ago

0.7.1-1a3b625.0

5 years ago

0.7.1-dddc6ae.0

5 years ago