What is the correct way to launch slimerjs in casperjs (with an absolute path)?

戏子无情 提交于 2019-12-05 10:19:19
Fanch

Answer -> i finally found a way that suits me : like this :

So i put slimer in PATH, and i have to have application.ini and omni.ja at the same level as my directories contening my test files. That way it's not inconvenient, and i can launch my directories or files with slimerJS.

See also Git Issue


EDIT : Here the best solution : install it via npm : npm install -g slimerjs -g to be available everywhere. And that's it, juste choose your --engine=slimerjs with casper and it works. Thx for this node module.

For the best way to install phantomjs + casperjs + slimerjs without PATH and OS compatibility headlock :

npm install -g phantomjs
npm install -g casperjs
npm install -g slimerjs

In windows the exe will be set here : C:\Users\UserName\AppData\Roaming\npm (you don't need to put them in PATH, node -npm actually- manages it with the -g flag).

Keep in mind slimerjs has some relative path problems, so to keep the compatibility between phantom and slimer, use fs.workingDirectory, see Is there a way to step in to CasperJS code and Debug step by step

Darren Cook

Put slimerjs into the Windows path. You can test this will work by doing:

set PATH=%PATH%;C:\bin\slimerjs
casperjs --engine=slimerjs test.js

If that is good, you can set it globally. Here is an SO question on how to do that programmatically: How to update PATH variable permanently from cmd? Windows And here is one of many pages on how to do it from the GUI: http://www.computerhope.com/issues/ch000549.htm

As another idea, I wonder if the casper script needs double backslashes, so perhaps it should look like:

'default_exec' : 'C:\\bin\\slimerjs\\slimerjs.bat'

If you are running in Windows, you should set the SLIMERJS_EXECUTABLE environment variable. If you have already done the install recommended by Fanch then skip to step


Recommended Installation:

  1. Install Chocolatey (open command prompt as an administrator)

    @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
  2. Install NodeJS

    choco install nodejs.install
  3. Install SlimerJS, PhantomJS and CasperJS

    npm install -g slimerjs
    npm install -g phantomjs
    npm install -g casperjs
  4. FIX Casperjs.cmd
    There is a problem with the default installation of CasperJS in which it tries to load it via python. While this is ok, CasperJS comes with a native .Net executable and that's what you should use to run CasperJS on Windows. To fix this, edit the casperjs.cmd file in %APPDATA%\npm folder

    notepad %APPDATA%\npm\casperjs.cmd

    and replace the contents with this:

    @ECHO OFF
    SET PHANTOMJS_EXECUTABLE=%APPDATA%\npm\node_modules\casperjs\node_modules\phantomjs\lib\phantom\phantomjs.exe
    SET SLIMERJS_EXECUTABLE=%APPDATA%\npm\slimerjs.cmd
    %~dp0\node_modules\casperjs\bin\casperjs.exe %*
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!