Skip to content

Nightwatch test doesn't fail if element was not found #4405

@maxi-mueller

Description

@maxi-mueller

I am using Nightwatch + Cucumber for some automated tests and I noticed that when a element can't be found then functions like click and sendKeys won't fail the test. The error message is shown in the console like:
An error occurred while running .sendKeys() command on <.demo>: Timed out while waiting for element ".demo" with "css selector" to be present for 5000 milliseconds.
but the rest of the test will continue. My nightwatch default profile includes those flags:

suppressNotFoundErrors: false,
abortOnAssertionFailure: true,
abortOnElementLocateError: true,

Here is some example code (notice that i am using the page object model)

  login: async function(email, password) {
    await this.sendKeys('@emailField', email)
    await this.click('@continueButton')
    await this.sendKeys('@passwordField', password)
    await this.click('@confirmPasswordButton')
    await this.expect.element('@uniquePageElement').to.not.be.present;
  },

Also, is it correct to not chain the commands?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions