在浏览器中运行seleniumbuild设者的摩卡testing

我如何在浏览器中运行testing?

我使用seleniumbuild设者来记住步骤,然后我导出file.js并运行它在摩卡(npmtesting)。 testing成功,但我不能打电话给浏览器。

如果我导出file.java并在eclipse中运行它,一切正常,但在摩卡我不能调用任何浏览器。

我已经把驱动(如geckodriver的FF)在给定的文件夹中,通过npm安装selenium服务器等,有不同的设置file.js为浏览器,命令等,但浏览器将不会出现,当我在摩卡运行testing。 (我正在使用Windows)。

我可以运行由selenium builder(.json)编写的testing。 以前在命令行启动selenium服务器; 我可以通过SeInterpreter(没有seleniumbuild设者)运行testing(.json)。 但是,我怎样才能打电话给浏览器,看我以前写过的步骤?

这是代码示例:

 var assert = require('assert'); var wd = require('wd'); chai = require('chai'), expect = chai.expect, _ = require('underscore'), fs = require('fs'), path = require('path'), uuid = require('uuid-js'); var VARS = {}; // This assumes that selenium is running at http://127.0.0.1:4444/wd/hub/ var noop = function() {}, b = wd.promiseChainRemote(); describe('Selenium Test Case', function() { this.timeout(60000); it('should execute test case without errors', function(done) { b.chain(function(err) { done(err); }) .init({ browserName: 'firefox' }) .get("https://google.com") .elementById("lst-ib", function(err, el) { b.next('clear', el, function(err) { b.next('type', el, "приветик", noop); }); }) .elementById("lst-ib", function(err, el) { b.next('clear', el, function(err) { b.next('type', el, "приветик", noop); }); }) .elementByLinkText("Картинки", function(err, el) { b.next('clickElement', el, noop); }) .close(function(err) { done(err); }); }); }); 

提前致谢!!!

你可以导出你的testing案例为“Node.JS – Selenium WebDriver”通过文件 – >导出(在seleniumbuild设者插件 – logging脚本后),并确保将其保存为'somefile.js'(javascript)。您可以在命令提示符下执行它作为“node filename.js”,并在action中看到它。希望它有帮助!