Search code examples
testingwebselenium-webdriverfunctional-testingintern

How to debug functional testing with intern js


I am new to functional testing and to intern. Can anybody help me with the functional testing of the web pages which require authentication i.e. web pages behind the session. I have installed the selenium web driver and able to test the login page and some static pages without any issues.

e.g. /myproj/login is login page. I am able to test it. Now when I am trying to test /myproj/home/index then browser is redirecting to login page. I want to test this page what should be the steps? Some code snippet would really make the things clear.

registerSuite({
        name: 'demo',

        'submit form': function () {  
            remote = this.remote;
            return remote
                .get(require.toUrl('https://localhost/login'))
                .findById('username')
                    .click()
                    .type('test')
                .end()
                .findById('password')
                    .click()
                    .type('test123')
                .end()
                .findByName('submit')
                    .click()
                .end()
                .then(pollUntil('return document.getElementById("osp_homepage_metric_selection_bar");', 30000))
                .findById('osp_show_help_popup_trigger_parent')
                .getVisibleText()
                .then(function(resultText){
                    assert.equal(resultText, '<i class=" icon-question-sign"></i>','Test Failed!!!');
                });
        },

        'landing page': function () {    
            return remote
                .setFindTimeout(Infinity)
                .findById('show_help_popup_trigger_parent') 
                .getVisibleText()
                .then(function (resultText) {
                    assert.equal(resultText, '<i class=" icon-question-sign"></i>','Test Failed!!!');

                });
        }


    });

Thanks In Advance

Manish


Solution

  • One possibility is to use a test server that doesn't require you to login.

    Another option would be to login to your site in your functional test. Fill in the username and password (or whatever you use to login) on the login page and submit it:

    .findById('username')
    .type('bob123')
    .end()
    .findById('password')
    .type('somepassword')
    .end()
    .findById('submit')
    .click()
    

    Then wait for the page you're interested in to load completely and continue testing:

    .then(pollUntil(...))
    // continue testing
    

    If the login process is slow, you may need to increase the timeout for your test using this.async.