Wednesday 26 April 2017

Nightmare hangs on goto()

I have been recently working with NightmareJS and I am now having a problem. It seems as though whenever I try to load a page using Nightmare and wait for a selector to exist, it hangs on the goto call. I have the following code and the only thing printed to console is "loading".

nm = new Nightmare({show: false});

console.log("loading");

nm.goto("https://www.google.com")

.then(() => {
  return nm.wait(".gbqfba")
  .then(() => {
    console.log("search bar loaded, showing browser");
    nm.show();
  })
  .catch((err) => {
    console.log(err.toString());
  })
})
.catch(error => console.log('An error occurred:', error));

(the class 'gbqfba' is a hidden part of the search bar that I wait for so I know the bar is loaded)



via Cameron

No comments:

Post a Comment