Why PhantomJS When You Can Chrome
Following our unfortunate bug in Shoov which caused login to stop working, we decided to write a Behat test that will continuously check the live site and make sure login with GitHub is working properly.
Writing the Behat test was pretty easy, however it had a major problem - it didn't work.
<span class="nt">@javascript</span><span class="nf"></span><span class="k">Scenario:</span><span class="nf"> Login to shoov</span><span class="k"> Given </span><span class="nf">I am an anonymous user</span><span class="nf"> </span><span class="k">When </span><span class="nf">I visit the homepage</span><span class="nf"> </span><span class="k">And </span><span class="nf">I login with my GitHub account</span><span class="nf"> </span><span class="k">Then </span><span class="nf">I should wait for the text "</span><span class="s">My Account</span><span class="nf">" to "</span><span class="s">appear</span><span class="nf">"</span>
When Behat sees the @javascript
tag in the begining of the scenario, it launches it (with the help of Mink extension) in PhantomJS, Firefox or Chrome.
PhantomJS is usually the easiest to configure and hook into the CI workflow later on.
But the test we wrote just failed on all versions of PhantomJS we tried. Which made us switch to Firefox instead. Travis CI is kind enough to have a headless Firefox installed in their machine which we could use. Unfortunately, Firefox didn't like our test either, but for another reason - it couldn't parse the xpath we use to find our text elements.
So after spending some time trying to figure out a workaround, I suddenly stared at the browser I was using to find the answer - Chrome!
Behat test running on headless Chrome, seen via VNC