Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsafe javascript attempt to access frame when installing casperjs through npm windows

I have installed casperjs and phantomjs on my windows machina via npm. However I get this issue.

C:\>casperjs sample.js

C:\>Unable to open file: sample.js
Unsafe JavaScript attempt to access frame with URL about:blank from frame
with URL file:///C:/Users/vini/AppData/Roaming/npm/node_modules/casperjs/bin/bootstrap.js.
Domains, protocols and ports must match.
like image 621
vini Avatar asked Mar 29 '15 08:03

vini


1 Answers

This is a known issue with CasperJS and the 1.9.8 version of PhantomJS. It doesn't do anything and the errors are only printed during exit. They don't interfere with your script. There is a workaround and it was merged into master branch on GitHub, but it is not available as a release of CasperJS yet (latest is 1.1-beta3).

The easiest way to solve this is to downgrade to PhantomJS 1.9.7. Since you're using NPM it is easily done with

npm -g install [email protected]

The PhantomJS versions match with the NPM phantomjs package versions up until 1.9.7, then everything breaks. You can check the versions with npm show phantomjs.

If you downgrade to version 1.9.7, you will have to run with the --ssl-protocol=any commandline option for sites that request https resources. The reason is shown in my answer here.

The proper way to solve this is to install a new version from git. This will enable you to not only use PhantomJS 1.9.8 without the additional error lines, but also PhantomJS 2 which would not be possible with CasperJS 1.1-beta3.

References:
GitHub issue #1068
Workaround for CasperJS #1139
PhantomJS issue on SO

like image 108
Artjom B. Avatar answered Nov 19 '22 10:11

Artjom B.