question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

before async launches multiple browser windows

See original GitHub issue

Strange behaviour I am experiencing when using before. I have to always use the async version as otherwise my tests timeout. But as soon as I do use the async version it opens two browsers, one is blank.

I’m following the docs here: http://nightwatchjs.org/guide#using-before-each-and-after-each-hooks which says that I can indeed use it without a callback,

  // Lanuches a single browser but times out because done() has not been called.
  // "Error: timeout of 20000ms exceeded. Ensure the done() callback is being called in this test."
  before(client => {
      client.url('http://google.com');
  });
  // Launches two browser windows and the first `it` fails because
  // it runs on the second window which has not navigated to the right URL.
  before((client, done) => {
      client.url('http://google.com');
      done();
  });

node v4.2.3 nightwatch 0.9.3 with mocha test runner

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Dec 9, 2017

I had this problem as well - that two windows were opened with browser.url inside beforeEach and only one of the browsers loads up the url provided.

I was able to solve it by pushing the steps inside browser.status as follows:

function beforeEach(browser, done) {
    // getting the session info
    browser.status(function (/*result*/) {
        // console.log(result.value);
        browser.url('http://www.google.com');
        done();
    });
}

@beatfactor is this correct? Should this be added maybe as a comment inside the example at link: https://github.com/nightwatchjs/nightwatch-docs/blob/master/guide/using-nightwatch/external-globals.md

0reactions
stale[bot]commented, Nov 14, 2018

This issue has been automatically marked as stale because it has not had any recent activity. If possible, please retry using the latest Nightwatch version and update the issue with any relevant details. If no further activity occurs, it will be closed. Thank you for your contribution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple Browser Windows | Advanced Guides - TestCafe
Multiple Browser Windows. The TestCafe API includes methods that open, close, and switch between browser windows. You can test websites with pop-up windows...
Read more >
Puppeteer: How to handle multiple tabs? - node.js
browser.pages() · Override the window.open function: await page. · Go to your first page and perform some actions: await page.goto(PAGE1_URL) // .
Read more >
Walkthrough: Accessing the Web by Using Async and Await
This walkthrough starts with a synchronous Windows Presentation Foundation (WPF) application that sums the number of bytes in a list of websites ...
Read more >
Process asynchronous tasks as they complete (C#)
By using Task.WhenAny, you can start multiple tasks at the same time and process them one by one as they're completed rather than...
Read more >
Asynchronous Programming with Async and Await - Visual Basic
Asynchrony proves especially valuable for applications that access the UI thread because all UI-related activity usually shares one thread.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found