没有断言 运行 与守夜人 js

No Assertions Ran with night watch js

大家好,我正在自学夜视 js。我正在尝试使用页面对象模型,但遇到了一些问题。基本上每当我执行我的代码时,我都会在控制台中看到消息 "No assertions ran" 。有人可以解释一下吗?

我正在测试的URL是: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();
        }

   }

是的,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)