javascript - 如何使用 nightwatch.js 依次运行一系列“功能”测试
问题描述
我有一个非常长的功能测试,从我的 Web 应用程序的登录面板开始,一直到更深层次的功能。这是我第一次使用 nightwatch.js - 我想知道是否有办法将这个庞大的函数分解为多个分段的函数,并按顺序运行。我尝试过,从字面上将其分解为单独的函数,就像我的主要的大型函数一样,我也尝试将每个单独的函数包装在两者之间'browser'
,'browser.end();'
但这也不起作用 - 发生的是,它们没有按顺序运行 - 所以当然他们没有找到下一个基础元素等,因为它重新开始。有什么建议吗?
this.LoginScreen = function(browser) {
browser
.url(Data.urls.home)
.waitForElementVisible('#login', 1000, false)
.click('#login')
.waitForElementVisible('div.side-panel.open', 4000, false)
// Ton more here, i'd like to modulate
Errors.checkForErrors(browser);
browser.end();
};
解决方案
这非常简单,可以在 Nightwatch 入门页面http://nightwatchjs.org/gettingstarted中找到
module.exports = {
'Verify Added customer': function (browser) {
// In above first function with name 'Verify Added customer'
browser
.click(rc.registeredCustomers)
.pause(t.averagePauseLimit)
},
'Verify Email Button Present': function (browser) {
// in above there is second function
browser
.click(rc.registeredCustomers)
.pause(t.averagePauseLimit)
.getText(rc.primaryEmail, function (result) {
this.assert.equal(result.value, 'Primary : ' + email)
})
.pause(t.minimumPauseLimit)
.click(rc.verifyCustomer)
.pause(1000)
.assert.elementNotPresent(rc.verifyEmail, 'Verify Email is not present')
},
推荐阅读
- blogger - 如何编辑博客 HTML 以在移动主题中显示默认搜索框?
- javascript - Popper popovers 没有正确遵循旋转的 popper 参考
- javascript - d3 v4 地图意外变空
- git - 我无法在 Digital Ocean 上进行远程部署
- java - 为什么数据文件中的count值不递增?
- geolocation - Json 文件未加载到 folium 地图上
- matlab - 取矩阵列的平均值
- r - R 中 gtools::mixedsort 包的奇怪行为
- javascript - 使用 Google Chart API 在堆积条形图中使用符号注释
- python - 下拉列表更改时将值传递给烧瓶路线