-
-
Notifications
You must be signed in to change notification settings - Fork 634
Selenium Server w/ PhantomJS : Trying to achieve a Visual Regression Testing Strategy #421
Description
I'm in pursuit of a "Unified Development Environment", mixed Mac & Windows devs. I've been super happy with the Drupal-VM project and with everyone's help so far on my other questions. The last piece I'm trying to get in place is figuring out a strategy for visual regression testing.
@geerlingguy, Per your post here, you mentioned that you don't recommend the Selenium PhantomJS route on the VM:
Yes, you can get it working inside Drupal VM with the ability to do screenshots through the phantomjs driver... but I usually recommend people either set up CI with that level of detail/automation on a separate server (e.g. Jenkins) or on their host machine, since it will use an actual browser instance, like FireFox. Drupal VM is much better imo for building the tests with a headless browser, though you can get it working either way (if you want screenshots).
I'm wondering why? From an unified development environment perspective, seems like it would be better if everyone on the team could fire up a VM, with all the necessary config, do a git pull to their share filesystem folder, maybe a database sync, and be up and running...
Continuous Integration During Development
I'd like some sort of watch task running while styling and site building that would run the behat tests and another task runner for CSS themers. I haven't really figured out when it makes logical sense to run diffs. Every save? Every commit? only on release? I could see potential benefit to each. That seems like something we can figure out given our workflow if I can get everything up and running though.
I am pretty confident I will want to run all behat tests and visual regression tests on commit as well as a pre-commit hook before deployment to prod. Any tips/pointers for how to get this setup? I'd like to do this on Travis CI but not really sure where to go from here.
In writing this all out I'm realizing I'm probably asking like 5 questions here and only a few of them are directly related to this project. This would probably also better be a blog post at this point but oh well...
Here is just some context of what I did to get things setup and working on my local host
- I'm able to run
behattests on the VM via the drupal-extension. Yay! 👍 - After getting the following prerequisites installed I'm able to generate screenshots and diffs via
webdriverio,phantomjs, andwebdrivercss. Yay! x 💯node v5.5on my local host (mac)- $ `npm install -g phantomjs@">1.0 <2.0"
- $ `npm install -g selenium-standalone"
- $ `npm install -g webdriverio@2.4.5
- $
brew install imagemagick// I think this was already installed but not 100% - $
brew install graphicsmagick// This was a fix to an oddgm converterror
Here's my globally installed node packages:
$ npm list -g --depth=0
├── npm@3.5.3
├── phantomjs@1.9.19
├── selenium-standalone@4.9.0
├── webdriverio@2.4.5
Here's my package.json:
{
"name": "vtests",
"version": "1.0.0",
"main": "webdrivercsstest.js",
"dependencies": {
"jquery": "^1.11.3",
"phantomcss": "^0.10.4",
"phantomcss-gitdiff": "^0.0.5",
"webdrivercss": "^1.1.9"
},
}Here's my actual webdrivercsstest.js
var assert = require('assert');
// init WebdriverIO
var client = require('webdriverio').remote({desiredCapabilities:{browserName: 'phantomjs'}})
// init WebdriverCSS
require('webdrivercss').init(client, {
screenWidth: [320,480,768,960,1280]
});
client
.init()
.url('http://drupalvm.dev')
.webdrivercss('startpage',[
{
name: 'page',
elem: '#page',
exclude: [
".container-to-exclude",
]
}
], function(err, res) {
assert.ifError(err);
assert.ok(res.page[0].isWithinMisMatchTolerance);
})
.end();The screen captures are generated as expected if I start the selenium server on my local machine via:
$ selenium-standalone start
and in another terminal run
$ node webdrivercsstest.js
I need to credit @lhridley https://github.com/lhridley for most of this based on the workshop she gave to the WebNY group a few months ago. This is in large part me just trying to grok the whole thing in my own way...
