Copied from my Stackoverflow question:
I was using Phantomjs
with Phoenix framework for test, and the package I use in phoenix is hound
. I previously installed phantomjs
with apt-get
which was giving problems (this github comment said the installation method was the culprit), so I downloaded the latest binary from the official website but that was giving permissions denied error, so I had to build it from the source, but to my surprise the build.py which is mentioned in the official guide wasn’t avaialble, so I even failed to build it that way. I also failed to install through npm, so I gave up on phantomjs.
Now I installed slimerjs, but I don’t know what is slimerjs’s alternative command to phantomjs --wd
.
You can also use chrome-driver with hound. I won’t call it a truly headless experience, as it will show you a blink of the webpage, but it works.
You have to follow the following steps.
-
Download chrome driver.
- Run it. (through terminal, or just double click it)
- change
config :hound, driver: "phantomjs"
to config :hound, driver: "chrome_driver"
in your config/test.exs
.
done.
2 Likes
Yes, chrome driver shows Chrome browser for a moment which is annoying, but it’s OK, because I can continue learning Phoenix. 
Thank You!
Today I made phantomjs work by installing it through npm
with the command sudo npm install -g phantomjs-prebuilt --unsafe-perm=true --allow-root
(as it was getting failed with sudo npm install -g phantomjs-prebuilt
).
Using chrome driver was a pain, as it was showing a blink of the page for every single acceptance test, and was slow if you had more than a few tests.
I rushed to the Forum to share it with others, thinking it may be beneficial to others facing the same problem.
2 Likes