Skip to content

Pass local context to browser.debug() command.#4299

Merged
garg3133 merged 2 commits intonightwatchjs:mainfrom
garg3133:local-context-in-debug
Jan 16, 2025
Merged

Pass local context to browser.debug() command.#4299
garg3133 merged 2 commits intonightwatchjs:mainfrom
garg3133:local-context-in-debug

Conversation

@garg3133
Copy link
Copy Markdown
Member

With this enhancement in the browser.debug() command, users will now be able to pass the local variables from their test into the Debug mode and use them there.

Example

On running the below example, someLocalFunction and someLocalVariable will be directly available inside the DEBUG mode (along with browser) and can be used like a local variable.

function someLocalFunction() {
  console.log('local function running');

  return 'local function result';
}

describe('duckduckgo example', function() {
  it('Search Nightwatch.js and check results', async function(browser) {
    const someLocalVariable = 'something random';

    browser
      .navigateTo('http://duckduckgo.com')
      .click('input[name=q]');

    browser.debug({context: {someLocalVariable, someLocalFunction}});
  });
});
image

@github-actions
Copy link
Copy Markdown

Status

  • ❌ No modified files found in the types directory.
    Please make sure to include types for any changes you have made. Thank you!.

@garg3133 garg3133 changed the title Allow local context to be passed to browser.debug command. Pass local context to browser.debug() command. Jan 16, 2025
@garg3133 garg3133 merged commit 991f79d into nightwatchjs:main Jan 16, 2025
@garg3133 garg3133 deleted the local-context-in-debug branch January 16, 2025 18:36
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

Successfully merging this pull request may close these issues.

1 participant