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

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

Merged
merged 2 commits into from
Jan 16, 2025

Conversation

garg3133
Copy link
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

Copy link

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
16 of 17 checks passed
@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