how to run a series of 'function' tests, sequentially, with nightwatch.js

时间:2018-08-22 14:00:29

标签: javascript nightwatch.js

I have one really long function tests, that starts from the login panel of my web application and goes all the way through deeper features. It is my first time using nightwatch.js - I'm wondering if there is a way to break this huge function up, into multiple, segmented functions, that run sequentially. I tried, literally breaking it up into separate functions, just like my main, large one, I also tried wrapping each separated function in between 'browser' and 'browser.end();' but this also did not work - what happens is, they don't run sequentially - so of course they don't find the next underlying elements, etc. because it starts over. Any advice?

    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();
};

1 个答案:

答案 0 :(得分:0)

这非常简单,可以在Nightwatch入​​门页面http://nightwatchjs.org/gettingstarted

中使用
#i.e. I get this:               #when I should get this (only column 111 shown):

              067   083   111                 111
USC00040232  TRUE FALSE FALSE               FALSE
USC00041912  TRUE FALSE FALSE               FALSE
USC00043134  TRUE FALSE FALSE               FALSE
USC00044712  TRUE FALSE FALSE               FALSE
USC00047646  TRUE FALSE FALSE               FALSE
USW00023232  TRUE FALSE FALSE               FALSE
USW00023271  TRUE FALSE FALSE               FALSE
USC00041253 FALSE  TRUE FALSE               FALSE
USC00043402 FALSE  TRUE FALSE               FALSE
USC00046154 FALSE  TRUE  TRUE               FALSE
USC00047681 FALSE  TRUE FALSE               FALSE
USC00047902 FALSE  TRUE  TRUE               FALSE
USC00049111 FALSE  TRUE FALSE               FALSE
USW00023190 FALSE  TRUE FALSE               FALSE
USW00023273 FALSE  TRUE FALSE               FALSE
USW00093209 FALSE  TRUE FALSE               FALSE
USC00042941 FALSE FALSE  TRUE               FALSE
USC00044422 FALSE FALSE  TRUE                TRUE
USC00046399 FALSE FALSE  TRUE                TRUE
USC00046602 FALSE FALSE  TRUE               FALSE
USC00046940 FALSE FALSE  TRUE                TRUE
USC00048014 FALSE FALSE  TRUE               FALSE
USW00003159 FALSE FALSE  TRUE               FALSE
USW00023129 FALSE FALSE  TRUE               FALSE
USW00023136 FALSE FALSE  TRUE                TRUE
USW00023187 FALSE FALSE  TRUE                TRUE
USW00093111 FALSE FALSE  TRUE                TRUE
USW00093134 FALSE FALSE  TRUE               FALSE