Making casperjs work with slimerjs on Windows
results in two errors:
- CLI: The command “Files” was not found. (or something like that)
- Popup: Couldn’t read application.ini
The command “Files” was not found.
slimerjs uses an environment variable SLIMERJSLAUNCHER to contain the path to the Firefox executable. On my environment that is “C:\Program Files (x86)\Mozilla Firefox\firefox.exe”.
Since it usually contains spaces it needs to be wrapped in quotes. That is, presumably, why the developers used
at the top of their slimerjs.bat. Now, if you set the environment variable to include quotes in the first place, or if the batch file is executed twice in the same CLI session, it suddenly looks like that: “”C:\Program Files (x86)\Mozilla Firefox\firefox.exe””.
Couldn’t read application.ini
Firefox needs an application.ini to run. In the slimerjs folder there is one. If using slimerjs standalone this is fine as slimerjs.bat contains
which is the path to the executing batch file.
When executing from casperjs, however, this fails, and %~dp0 is set to the working directory (where you execute the script).
I had to “hack” the slimerjs.bat to make it work standalone and with casperjs.
- Open slimerjs.bat and replace around line 3
and make sure your environment variable includes the necessary quotes.
- Add a new environment variable called SLIMERDIR and set it to your slimerjs directory. Now in slimerjs.bat replace around line 7
if not exist %SLIMERDIR% (
This might not be the cleanest solutions but they work. Hopefully these issues will be resolved in future versions of casperjs/slimerjs.