问题
In the cucumber-js page is showed an example with Zombie:
// features/support/world.js
var zombie = require('zombie');
var WorldConstructor = function WorldConstructor(callback) {
var browser = new zombie();
var world = {
browser: browser, // this.browser will be available in step definitions
visit: function(url, callback) { // this.visit will be available in step definitions
this.browser.visit(url, callback);
}
};
callback(world); // tell Cucumber we're finished and to use our world object instead of 'this'
};
exports.World = WorldConstructor;
It is possible use Phantomjs instead of Zombie?
Can someone show me an example of world.js with it ?
Thanks.
回答1:
Finally I found the solution:
// features/support/world.js
var webdriver = require("selenium-webdriver");
var WorldConstructor = function WorldConstructor(callback) {
var world = {
driver: new webdriver.Builder()
.withCapabilities(webdriver.Capabilities.phantomjs())
.build()
};
callback(world);
};
exports.World = WorldConstructor;
I had to install phantomjs:
npm install phantomjs
Chromedriver
You can also use chromedriver as follows:
npm install chromedriver
Remember to change driver to:
driver: new webdriver.Builder()
.withCapabilities(webdriver.Capabilities.chrome())
.build()
来源:https://stackoverflow.com/questions/29451362/cucumber-js-world-constructor-example-with-phantomjs