Upgrading casperjs to use phantomjs 2.0 from 1.9.8

﹥>﹥吖頭↗ 提交于 2019-12-12 00:16:24

问题


I read that people have found ways to get casperjs to work with phantomjs 2.0 but how could I do the upgrade? For example just swapping out phantomjs folder in /usr/.../casperjs/node_modules/phantomjs with a folder for phantomjs2 doesn't seem to do the trick. I've also made the changes in lib/bootstrap.js to handle the warnings from using 2.0.

I'm using mocha-casperjs to create my tests.


回答1:


If you want to use PhantomJS 2, then you currently need to either

  • install CasperJS from git (which supports PhantomJS 2) and change the fixed path in mocha-casperjs or
  • remove the PhantomJS version checks in CasperJS as seen here

Change the fixed path in mocha-casperjs (in mocha-casperjs/bin/mocha-casperjs) from:

$mcPath/../../casperjs/bin/casperjs $mcPath/cli.js --mocha-casperjs-path=$mcPath/.. $*

to

path/to/casperjs $mcPath/cli.js --mocha-casperjs-path=$mcPath/.. $*

or if casperjs is in the PATH:

casperjs $mcPath/cli.js --mocha-casperjs-path=$mcPath/.. $*

PhantomJS versions

I suggest that you also preserve multiple versions of PhantomJS and switch between them if you need it. Currently there is no official PhantomJS 2 version, so you will need to build it yourself or trust zeevl who seems to have compiled PhantomJS 2 for Linux:

npm -g install phantomjs2


来源:https://stackoverflow.com/questions/31170153/upgrading-casperjs-to-use-phantomjs-2-0-from-1-9-8

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