Zombie Browser Will Not Open Window After Calling Open Function

tools

attempt 1

  • Darwin 14.3.0 The core of Darwin Version 14.3.0
  • io.js v1.8.1
  • zombie Version 4.0.7 2015-04-10

attempt 2

  • Linux ubuntuG5 3.13.0-48-powerpc64-smp
  • node.js v0.10.38
  • zombie Version 3.1.0 2015-03-15

commands:

const Browser = require('zombie'); var url = 'https://google.com' var browser = new Browser(); browser.open(url=url) browser.open('http://google.com', function(err) { browser.assert.success(); }); browser.assert.text('title', 'Google'); 

Results on both machines minus differences in file path:

  assert.js:93 throw new assert.AssertionError({ ^ AssertionError: No open window with an HTML document at Browser.queryAll (/home/dmmmd/Dropbox/node_js_projects/node_modules/zombie/lib/index.js:432:5) at Assert.text (/home/dmmmd/Dropbox/node_js_projects/node_modules/zombie/lib/assert.js:307:33) at Object.<anonymous> (/home/dmmmd/Dropbox/node_js_projects/affinity-zombie/sample_zombie.js:7:16) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:935:3 

What am I missing after reading documents in a zombie browser ? Thanks in advance.

I also tried some other urls, even without local hosts.

JavaScript, node.js, io.js and zombies are all new to me, so I mainly follow recipes from documentation questions and stackoverflow. I would be grateful for any suggestions. I suspect that I am missing something very simple.

+7
source share
1 answer

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'); }); 
  1. 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'); }); 
  1. 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'); }); 
  1. 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(){}); // NB: no-op callback! browser.assert.text('title', 'Stack Overflow'); 

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.

+1
source share

All Articles