This question went unanswered for a while, but recently I was working on a similar error message.
TL; DR - User browser.visit instead of the .open () browser and pass a callback function to make sure the browser state is filled correctly.
You can do this in several ways:
- Use the static method Browser.visit ()
const Browser = require('zombie'); var url = 'https://stackoverflow.com' Browser.visit(url, function(error, browser) { browser.assert.text('title', 'Stack Overflow'); });
- Use instance method browser.visit ()
const Browser = require('zombie'); var url = 'https://stackoverflow.com' var browser = new Browser(); browser.visit(url, function() { browser.assert.text('title', 'Stack Overflow'); });
- Use the promise returned by the browser .visit ()
const Browser = require('zombie'); var url = 'https://stackoverflow.com' var browser = new Browser(); browser.visit(url).then(function() { browser.assert.text('title', 'Stack Overflow'); });
- If you want to reuse the browser object after the visit, pass the no-op callback to browser.visit () to ensure that the state of the browser is populated.
const Browser = require('zombie'); var url = 'https://stackoverflow.com' var browser = new Browser(); browser.visit(url, function(){});
The browser.open () method opens a new browser tab and accepts a JavaScript object containing the url property, so the source code had a syntax error, line
browser.open(url=url)
must read
browser.open({url: url})
but it is unclear whether the open method really makes the new tab a visit to the URL — at least not from a fluent read through the source. Use browser.visit () to be safe.
Jim riordan
source share