我怎么能运行在浏览器中测试?硒建设者运行摩卡测试在浏览器
我用硒建设者要记住的步骤,然后我导出file.js
和摩卡(NPM测试)运行它。测试成功,但我无法调用浏览器。
如果我导出file.java
并在eclipse中运行它,一切正常,但在摩卡我不能调用任何浏览器。
我已经把驱动程序(例如geckodriver for FF)放在给定文件夹中,通过npm安装selenium服务器等等,对于浏览器,命令等,file.js
有不同的设置,但浏览器不会出现当我在摩卡运行测试。 (我正在使用Windows)。
我可以运行它是由硒制造商(以.json)编写了测试。先前在命令行中启动了硒服务器;我可以通过SeInterpreter(不含硒建造者)运行测试(.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);
});
});
});
在此先感谢!
非常感谢你的建议!一切正常,当我使用它!但是,当我尝试导出为'Node.JS - Mocha'时,在这种情况下,由于某种原因它将不起作用!我不能在命令提示符下将它作为'npm filename.js'来执行,并且出于某种原因在行动中看到它! –