capybara-envjs icon indicating copy to clipboard operation
capybara-envjs copied to clipboard

alert is not defined

Open grosser opened this issue 15 years ago • 4 comments

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:

grosser avatar Mar 25 '10 14:03 grosser

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 avatar Mar 25 '10 15:03 smparkes

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 avatar Mar 25 '10 15:03 smparkes

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.

smparkes avatar Mar 25 '10 16:03 smparkes

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

Papipo avatar Jul 10 '10 13:07 Papipo