Cucumber-js:使用phantomjs的世界构造函数示例 [英] Cucumber-js: World constructor example with phantomjs

查看:92
本文介绍了Cucumber-js:使用phantomjs的世界构造函数示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

黄瓜js页面中,显示了Zombie的示例:

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;

可以使用Phantomjs代替僵尸吗?

It is possible use Phantomjs instead of Zombie?

有人可以给我看一个world.js的例子吗?

Can someone show me an example of world.js with it ?

谢谢.

推荐答案

最后我找到了解决方法:

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;

我必须安装phantomjs:

I had to install phantomjs:

npm install phantomjs

Chromedriver

您还可以按以下方式使用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()

这篇关于Cucumber-js:使用phantomjs的世界构造函数示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆