我正在 Meteor 应用程序中进行我的第一组 Cucumber 测试,但我无法让登录步骤正常工作。我的应用程序使用了我专门为这个项目编写的自定义登录插件。这是步骤,因为我目前使用调试输出定义了它:
this.Given(/^I am logged in as a\/an "([^"]*)"$/, function(roleName, callback) {
this.browser
.url(url.resolve(process.env.HOST, '/'))
.waitForExist('#appSignIn');
this.browser.getHTML('#appSignIn', function(err, html) {
if (err) {
console.log('err: ', err);
} else {
console.log('link HTML: ', html);
}
});
this.browser.getCssProperty('#appSignIn', 'display', function(err, value) {
console.log('link HTML display: ', value);
});
browser.isVisible('#appSignIn', function(err, isVisible) {
console.log('#appSignIn', isVisible);
});
this.browser
.waitForVisible('#appSignIn')
.click('#appSignIn')
.waitForExist('#username')
.waitForVisible('#username')
.setValue('#username', 'test' + roleName)
.setValue('#password', 'test' + roleName)
.leftClick('#signin')
.waitForExist('#appSignOut')
.waitForVisible('#appSignOut')
.call(callback);
});
我在此日志中看到的是:
Scenario: # features/my.feature:11
Given The server data has been reset # features/my.feature:12
link HTML: <a id="appSignIn" href="/signin">Sign In</a>
link HTML display: { property: 'display',
value: 'block',
parsed: { type: 'ident', string: 'block' } }
#appSignIn false
And I am logged in as a/an "ADMIN" # features/my.feature:13
RuntimeError: RuntimeError
(ScriptTimeout:28) A script did not complete before its timeout expired.
Problem: Timed out waiting for asyncrhonous script result after 511 ms
基本上,我看到了 HTML 输出,所以我知道元素在那里。我看到 CSS 设置为display: block
,但 WebDriver 报告该元素在 isVisible 中不可见,并且类似地在waitForVisible
调用时超时。“登录”链接是位于右上角的 Bootstrap 可折叠导航栏的一部分。