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

筅森魡賤 提交于 2019-12-09 03:15:45

问题


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.

回答1:


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 phantomjs@1.9.7-15

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




回答2:


Use "phantomjs": "^1.9.9" And for caseperJs

casperjs --ssl-protocol=tlsv1 test  run.js


来源:https://stackoverflow.com/questions/29326956/unsafe-javascript-attempt-to-access-frame-when-installing-casperjs-through-npm-w

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!