smparkes / capybara-envjs

Capybara driver for envjs gem
http://github.com/smparkes/capybara-envjs
130 stars 10 forks source link

alert is not defined #1

Open grosser opened 14 years ago

grosser commented 14 years ago

just tried to use it, but only got xpath failure: ReferenceError: alert is not defined WARNIING: [Thu Mar 25 2010 15:19:48 GMT+0100 (CET)] {ENVJS} could not load script http://example.com/javascripts/scriptaculous.js?1269513576: alert is not defined ERROR: [Thu Mar 25 2010 15:19:49 GMT+0100 (CET)] {ENVJS} error evaluating script:

smparkes commented 14 years ago

This is actually an env-js issue (which I also support). Looks like our xpath engine doesn't have everything that prototype wants. We are looking at another engine or might be able to implement the pieces missing ... but I'm not sure when.

The workaound for now is disable xpath before loading prototype with something like

if (this.Envjs) { window.evaluate = undefined; }

smparkes commented 14 years ago

Oh, and by the way, the "alert" not defined is a bug that I'll check in a fix soon, but it was just hiding the real issue.

smparkes commented 14 years ago

Actually, the capybara driver needs access to xpath, so I'm pretty sure you'll need to save the reference and restore it, something like

var saved_evaluate = window.evaluate; if (this.Envjs) { window.evaluate = undefined; } include prototype if (this.Envjs) { window.evaluate = saved_evaluate; }

Kind of a pain ... sorry 'bout that. xpath is ... painful. Can't really fault prototype for trying to figure out if the xpath it has access to is working.

Papipo commented 14 years ago

I used this same fix to handle google dfp ads. loading the main script broke my tests.