Rich-text Reply

Testing of web site with zombie.js fails when the site loads the optimizely script

blarsen 10-07-14

Testing of web site with zombie.js fails when the site loads the optimizely script

We are using the headless simulated browser zombie.js (http://zombie.labnotes.org/, version 2.0.4) for testing our web sites, but our test suite fails when a site loads the Optimizely script. (https://cdn.optimizely.com/js/1914080109.js).

 

The error that occurs is

Cannot read property 'opacity' of undefined TypeError: Cannot read property 'opacity' of undefined
at <anonymous>:54:470
at optimizelyCode (<anonymous>:158:10)
at <anonymous>:280:1

 

The error occurs in the code for the embedded jQuery, but I have tracked the root cause down to the "Cleanse" part of the Optimizely code that apparently removes the style getters/setters from the window.HTMLelement in the zombie.js DOM.

 

Do you have any idea how we can handle this situation apart from removing the Optimizely code from our site?

 

 

Level 1

blarsen 10-07-14
 

Re: Testing of web site with zombie.js fails when the site loads the optimizely script

While I still would like a response from Optimizely I found a workaround for my problem by utilizing the zombie.js mocking feature to make it skip loading of the Optimizely code:

 

browser.resources.mock("https://cdn.optimizely.com/js/1914080109.js", {
  statusCode: 200,
  headers: { "ContentType": "application/json" },
  body: ""
});

Level 1
Gus 10-08-14
 

Re: Testing of web site with zombie.js fails when the site loads the optimizely script

Hi Blarsen,

This is interesting. Have you changed css attributes using Optimizely in the nodes where tests fail or does it fail everytime you try to access those values in any node, including those not changed by Optimizely?


Gus Ces
/Web (developer|analyst|CRO specialist)/g

Gus
Level 2