Last active
March 24, 2016 23:39
-
-
Save jdewit/8422507 to your computer and use it in GitHub Desktop.
world.js file for cucumberjs using phantomjs and protractor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('chai').assert, | |
path = require('path'), | |
browserName = process.env.browser || 'chrome', | |
protractor = require('protractor'), | |
webdriver = require('selenium-webdriver'), | |
exec = require('child_process').exec, | |
util = require('util') | |
; | |
var driver = new webdriver.Builder().usingServer('http://localhost:4444/wd/hub').withCapabilities(webdriver.Capabilities[browserName]()).build(); | |
driver.manage().timeouts().setScriptTimeout(100000); | |
var browser = protractor.wrapDriver(driver); | |
module.exports = function() { | |
this.registerHandler('AfterFeatures', function (e, done) { | |
browser.quit(); | |
if (browserName === 'chrome') { | |
exec('pkill chromedriver'); | |
} else if (browserName === 'phantomjs') { | |
exec('pkill phantomjs'); | |
} | |
setTimeout(function() { | |
done(); | |
}, 500); | |
}); | |
}; | |
module.exports.World = function World(callback) { | |
this.browser = browser; | |
this.By = protractor.By; | |
this.p = protractor; | |
this.assert = assert; | |
this.baseUrl = 'http://www.wardelladvisor.com'; | |
callback(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi jdewit,
How can i use this world.js with protractor + cucumberjs. Can u please provide me an example. like defining step definitions and execution.
Please do the need full.
Thanks,
Anil