Intern Functional Example2

intern

// Intern - Functional Testing - Example:

registerSuite({
    name: 'index',

    'greeting form': function () {
        return this.remote
            .get(require.toUrl('index.html'))
            .setFindTimeout(5000)
            .findByCssSelector('body.loaded')
            .findById('nameField')
                .click()
                .type('Elaine')
                .end()
            .findByCssSelector('#loginForm input[type=submit]')
                .click()
                .end()
            .findById('greeting')
            .getVisibleText()
            .then(function (text) {
                assert.strictEqual(text, 'Hello, Elaine!',
                    'Greeting should be displayed when the form is submitted');
            });
    }
});

In the above code, what is going on with the .end() method?  Notice that we do 
not specify the selector with the click method.  The find methods probably 
returns an object that implement the Promise API but also encapsulate the 
selector and support the click method, and the .end method, and the .end method 
is responsible for resolving the promise.

Also notice the .setFindTimeout method is invoked.

The find methods implicitly / automatically waits for the element to become 
present.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License