Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chaining page object commands off .pause(n) results in type error --> does not exist on type 'Awaitable<NightwatchAPI, undefined>' #4383

Open
reallymello opened this issue Mar 1, 2025 · 0 comments

Comments

@reallymello
Copy link
Contributor

Description of the bug/issue

When I use limited pauses mixed with page object commands I expect there to be no type errors when the commands are valid, but instead, after upgrading to v3.11.1 I receive error PageObjectCommandNameHere does not exist on type 'Awaitable<NightwatchAPI, undefined>'

e.g.

myPage.pause(200).myPageObjectCommand(); // Property 'myPageObjectCommand' does not exist on type 'Awaitable<NightwatchAPI, undefined>'.

Image

Steps to reproduce

  1. Create a typescript project setup with page objects
  2. In the page object create a page object command
  3. In the test, chain that command after a pause(n) statement

You should see the error. This was not occurring in v3.10.2

Sample test

import { NightwatchAPI, NightwatchTests } from 'nightwatch';
import { DuckPage } from '../page-objects/duckPage';

const home: NightwatchTests = {
  'Duck Duck go navigate': () => {
    const duckPage: DuckPage = browser.page.DuckPage();

    duckPage.navigate();
    duckPage.pause(200).clickRightOfToggleButton('dsf', 'sdf');
  },
};

export default home;

Command to run

N/A

Verbose Output

N/A

Nightwatch Configuration

// Refer to the online docs for more details:
// https://nightwatchjs.org/gettingstarted/configuration/
//

//  _   _  _         _      _                     _          _
// | \ | |(_)       | |    | |                   | |        | |
// |  \| | _   __ _ | |__  | |_ __      __  __ _ | |_   ___ | |__
// | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \
// | |\  || || (_| || | | || |_  \ V  V / | (_| || |_ | (__ | | | |
// \_| \_/|_| \__, ||_| |_| \__|  \_/\_/   \__,_| \__| \___||_| |_|
//             __/ |
//            |___/

module.exports = {
  // An array of folders (excluding subfolders) where your tests are located;
  // if this is not specified, the test source must be passed as the second argument to the test runner.
  src_folders: ['nightwatch/tests'],

  // See https://nightwatchjs.org/guide/concepts/page-object-model.html
  page_objects_path: ['nightwatch/page-objects'],

  // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
  custom_commands_path: [],

  // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
  custom_assertions_path: [],

  // See https://nightwatchjs.org/guide/extending-nightwatch/adding-plugins.html
  plugins: [],

  // See https://nightwatchjs.org/guide/concepts/test-globals.html
  globals_path: '',

  webdriver: {},

  test_workers: {
    enabled: true,
  },

  test_settings: {
    default: {
      disable_error_log: false,
      launch_url: 'http://localhost',

      screenshots: {
        enabled: false,
        path: 'screens',
        on_failure: true,
      },

      desiredCapabilities: {
        browserName: 'chrome',
      },

      webdriver: {
        start_process: true,
        server_path: '',
      },
    },

    chrome: {
      desiredCapabilities: {
        browserName: 'chrome',
        'goog:chromeOptions': {
          // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
          args: [
            //'--no-sandbox',
            //'--ignore-certificate-errors',
            //'--allow-insecure-localhost',
            //'--headless=new'
          ],
        },
      },

      webdriver: {
        start_process: true,
        server_path: '',
        cli_args: [
          // --verbose
        ],
      },
    },
  },
};

Nightwatch.js Version

3.11.1

Node Version

22.13.1

Browser

Chrome

Operating System

Windows

Additional Information

example project.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant