5

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.
Fenton
  • 241,084
  • 71
  • 387
  • 401
vini
  • 4,657
  • 24
  • 82
  • 170
  • Hello, it is best to include the actual text of errors or code as it is searchable and is easier for people helping you to copy and paste if they need to. – Fenton Mar 29 '15 at 09:29

2 Answers2

10

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

Community
  • 1
  • 1
Artjom B.
  • 61,146
  • 24
  • 125
  • 222
  • would this be solved if i install a previous version of phantomjs? – vini Mar 29 '15 at 08:42
  • how do i downgrade the version could you pls help with that – vini Mar 29 '15 at 08:56
  • This answer is gold, for anyone wondering this is still relevant as of today with npm casperjs and phantomjs – Frozenfire May 26 '15 at 20:08
  • I'm using the grunt plugin phantomcss where the same error occured. I downgraded the phantomjs node module but - the error doesn't occure anymore but the contents which I wanted to screenshot doesn't load anyway. So how to allow CORS in pahntomjs or casperjs? Within the plugin's js file I set `pageSettings: { webSecurityEnabled: false }, sslProtocol: 'any'` within casper.create but it didn't change anything – user2718671 Dec 14 '16 at 12:08
  • @user2718671 I have no experience with grunt or phantomcss. You could just ask a new question if you haven't done already. – Artjom B. Dec 14 '16 at 17:46
0

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

casperjs --ssl-protocol=tlsv1 test  run.js
PPB
  • 2,937
  • 3
  • 17
  • 12