我正在尝试使用webdriverIO学习更多的cucjs,并且在启动测试时遇到了一些麻烦。
实际上,我想介绍这个简单的功能:
Feature: Example Feature
In order to become productive
As a test automation engineer
I want to understand the basics of cucumber
Scenario: My First Test Scenario
Given I have open "https://google.com"
Then the title should be "Google".
And the bar should be empty.
通过这个测试:
const assert = require('assert');
module.exports = function() {
this.Given(/^I have open "([^"]*)"$/, function(arg1, callback) {
browser
.url(arg1)
.call(callback);
});
this.Then(/^the title should be "([^"]*)"\.$/, function(arg1, callback) {
// First solution
const title = browser.getTitle();
assert(title, arg1);
// Second solution
browser
.getTitle()
.then(title2 => {
assert(title2, arg1);
callback();
});
});
this.Then(/^the bar should be empty\.$/, function(callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
}
我的配置文件:
"use strict";
const WebDriverIO = require('webdriverio');
const browser = WebDriverIO.remote({
baseUrl: 'https://google.com', // Or other url, e.g. localhost:3000
host: 'localhost', // Or any other IP for Selenium Standalone
port: 4444,
waitforTimeout: 120 * 1000,
logLevel: 'silent',
screenshotPath: `${__dirname}/documentation/screenshots/`,
desiredCapabilities: {
browserName: process.env.SELENIUM_BROWSER || 'chrome',
},
});
global.browser = browser;
module.exports = function() {
this.registerHandler('BeforeFeatures', function(event, done) {
browser.init().call(done);
});
this.registerHandler('AfterFeatures', function(event, done) {
browser.end().call(done);
});
};
我的问题
我的问题是:
约束
编辑:我总是遇到超时问题
答案 0 :(得分:0)
使用chimpjs。它集成了webdriverio,黄瓜和其他朋友。它是“在光纤上”,因此您可以以同步方式编写测试。我使用它,当我必须使用我可以或需要的承诺时。