大家好,我每天都在教自己看js。我正在尝试使用页面对象模型,我遇到了一些问题。基本上每当我执行我的代码时,我都会看到消息"没有断言运行"在控制台中。有人可以解释一下吗?
我正在测试的网址是:https://www.nypl.org/
这是 /pages/homepage.js
var elements = {
searchbutton: '.nyplHomepageApp button[name = "Search Button"]',
Authortalksconversations: '.titleTabs #tab-0',
Exibitions: '.titleTabs #tab-1',
Performing_AF: '.titleTabs #tab-2',
Other_Events: '.titleTabs #tab-3',
DonateButton: '#donateButton',
Shop: '#shopTopLink',
loadicon: '.dcom-loader',
};
var quicksearch = {
go: function() {
return this
.waitForElementVisible('body', 6000)
.assert.visible('.nyplHomepageApp button[name = "Search Button"]')
.api.pause(4000)
.click('.nyplHomepageApp button[name = "Search Button"]')
.setValue('.desktopSearch-form-inputBox #desktopSearch-form-searchInput', 'history')
.pause(4000)
.click('button[type="submit"]')
.pause(4000)
end();
}
};
module.exports = {
elements,
commands: [
quicksearch,
]
};
这是tests / homepagetest.js
module.exports = {
'Q': function(browser) {
var goto = browser.page.homepage();
goto.go;
//browser.end();
}
}
答案 0 :(得分:0)
是的,quicksearch
不是一个功能,它是一个对象。您可以将其更改为
var quicksearch = function() {
//do stuff
}
或者您只需致电goto.go()
第一次暂停时,测试中也出现错误。将其更改为此,它将开始工作......
return this
.waitForElementVisible('body', 6000)
.assert.visible('.nyplHomepageApp button[name = "Search Button"]')
.api.pause(4000) //this is the change you need to make it work
.click('.nyplHomepageApp button[name = "Search Button"]')
.setValue('.desktopSearch-form-inputBox #desktopSearch-form-searchInput', 'history')
.pause(4000)
.click('button[type="submit"]')
.pause(4000)