我在将以下测试迁移到Mocha框架时遇到了麻烦:
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;
var driver;
var config = require('config');
var baseUrl = config.get('baseUrl');
var browsers = ['firefox', 'chrome'];
var flows = browsers.map(function (browser) {
return webdriver.promise.createFlow(function () {
driver = new webdriver.Builder()
// For remote server
.usingServer('http://127.0.0.1:4444/wd/hub')
.forBrowser(browser)
.build();
var loginPage = new LoginPage(driver, baseUrl);
loginPage.visit();
loginPage.login('jonnytest', 'elenbogen');
var photoViewPage = new PhotoViewpage(driver, baseUrl);
photoViewPage.visit();
photoViewPage.deleteAllComments();
driver.quit();
});
});
webdriver.promise.fullyResolved(flows).then(function () {
console.log('All tests passed!');
});
更具体地说,我可以使用selenium-webdriver在多个浏览器上并行运行相同的测试,但Mocha不会公开 control flow 。
我如何在Mocha中编写相同的测试?