5

slimerjs launch

Well, i can launch slimerjs by specifying the path of the slimer.bat file : C:\bin\slimerjs\slimerjs.bat and then execute my file.

But if i modify casperjs file (in bin\ ) and modify the default exec for slimer :

    'env_varname': 'SLIMERJS_EXECUTABLE',
    'default_exec' : 'C:\bin\slimerjs\slimerjs.bat'

when i execute the casper command :

    casperjs --engine=slimerjs test.js

It doesn't work, the path to slimerjs.bat seems to be ignored.

I tried this too : https://github.com/laurentj/slimerjs/blob/master/BUILD.md

But the slimerjs.exe alone isn't sufficient, i need to have application.ini and omni.ja in the current folder where i'm executing my tests, and i don't want to add some files in every folders.

What i want is just to execute slimerjs in casperjs with the engine property, whatever is the folder where i am, like in phantomjs so i need to set an absolute path (or relative path from root).

I don't want to be in the slimerjs.bat folder and specify the folder or js test i want to execute like that : casperjs test C:/bin/try/test.js --engine=slimerjs.

Here one similar issue : https://github.com/n1k0/casperjs/issues/591

Edit (thanks to Darren Cook for his answer) for more details :

set PATH=%PATH%;C:\\bin\\slimerjs

If i set a Windows PATH for slimer, when i execute casperjs test --engine=slimerjs test.js, i have this message :

fail slimerjs

But adding the two files in the test.js folder solves the problem.

path

So i think i have to modify the slimerjs bat file, to set the :callexec path from the slimerjs.bat folder, not the current test.js folder.

Here :

:callexec
if ["%HIDE_ERRORS%"]==[""] (
    %SLIMERJSLAUNCHER% -app "%SLIMERDIR%application.ini" %PROFILE% -attach-console -no-remote %__SLIMER_ARGS%
) ELSE (
    %SLIMERJSLAUNCHER% -app "%SLIMERDIR%application.ini" %PROFILE% -attach-console -no-remote %__SLIMER_ARGS% 2>NUL
)

with :

SET SLIMERDIR=%~dp0

The problem is that i'm not familiar with this syntax (batch file), it might be already correct and the problem doesn't come from here.

But what i observe is that it seems to look for application.ini and omni.ja from the current folder, not the slimerjs folder.

PS : second idea doesn't work but now i know it comes from slimerjs.

EDIT:

REM % ~ d[rive] p[ath] 0[script name] is the absolute path to this bat file, without quotes, always.
REM ~ strips quotes from the argument

So the path seems to be good, and in fact it works with slimerjs alone : slimerjs test.js works great and it doesn't ask for application.ini. So it's the combination of the two which doesn't work.

When you launch it with the casper command, the path is different (current folder) , and application.ini isn't recognized any more.

1
  • Please do not edit in an answer in the question itself. If you found the solution, post it below as an answer. May 21, 2014 at 15:31

3 Answers 3

6

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

SlimerArchOk

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

1

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'
3
  • Thanks for your answer, to put it globally i could do it with advanced systems settings too. In fact, when i put it in the Windows path, that doesn't work because it asks me to add application.ini and omni.ja in the folder where test.js is. The problem is when it executes my bat file (it works to put it in PATH), i think it looks for others files needed from the current folder, not from the slimerjs.bat folder. I'm editing my question to show you.
    – Fanch
    Feb 27, 2014 at 9:58
  • It PATH, you specify paths as C:\bin\slimerjs, not as C:\\bin\\slimerjs (i.e. use single backslashes).
    – Andriy M
    May 23, 2014 at 7:28
  • Thanks Andriy M. I don't have a windows machine to hand to test, but that sounds right, so I've edited my answer. May 23, 2014 at 7:34
0

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 %*

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.