Get help with testing, discuss unit testing strategies etc.


Post by nuridesengin »

Hello again. CI adapted tests are getting a lot of timeout errors. Normally it takes 761ms to load contents when running the application on web browser. But it takes to much longer when Selenium web driver runs the application and tests are keep failing through this error below;
Error happened before the test started
Waiting for Ext.onReady took too long - probably some dependency could not be loaded. 
Check the `Net` tab in Firebug and the `loaderPath` config
I've already used timeout, isReadyTimeout configs as you'll notice on first method that runs on tests. But probably not enough or correct to avoid from this error. Is there any better approach to run test cases?

BaseClass:
Class('Siesta.Test.ListScreen', {
    isa     : Siesta.Test.ExtJS,

    methods: {
        login : function(callback){
            var t = this;

            this.chain(
                { waitForCQ : 'window[title=Login]', timeout: 50000, isReadyTimeout: 20000},

                function(next) {
                    t.cq1(textField + '[name=username]').setValue('user@mail.com');
                    t.cq1(textField + '[name=password]').setValue('superPassword');
                    next();
                },

                {click: button + '[text=Submit]'},
                {waitForCQNotVisible: 'window[title=Login]', desc: 'Submit process is succeed!'},

                function(next) {
                    console.log('login func log...');
                    next();
                },

                callback
            )
        },
Inherited test assertion:
describe('Cloud App: Monkey Test', function (t) {
    t.it('Should Login to App and doing some clicks on dashboard', function (t) {
        t.chain(
            {
                login: t.next
            }
        )
    });

Post by nickolay »

The "isReadyTimeout" is not related to "waitForCQ" method. It should be specified as the config option in the test descriptor (in the "index.js")

Post by nuridesengin »

So.. isReadyTimeout config is can overcome on that situation?

and where I should defined it? On harness.configure or inside harness.start as this way?
{
        group: 'UI Tests',
        isReadyTimeout      : 20000,
        items: [
            {

Post by nickolay »

On "harness.configure()" it will be global for the whole suite. In the code you posted the config will affect only the "UI Tests" group.

Yes, if its only a slow network, then increasing this config should help.

Post by nuridesengin »

Dear nickolay hello again.

I've notated isReadyTimeout on harness.configure as you mentioned and i did not face with any error based on "Timeout" for a while but now it started again!

As well somehow test suite gives error for several test cases spontaneously with this error below;
TypeError: a.pseudos[d] is not a function
        at line 6, character 565881, of https://www.myapp/classic/app.js
When I ran test suit on local environment mostly passes whole cases. And when I ran through commands on CI server mostly throw this error but always for a different test case. Could you please give any advice for CI test cases;
harness.configure({
    title               : 'MyApp Test Runner',
    viewDOM             : true,
    enableCodeCoverage  : true,
    coverageUnit        : 'file',
    waitForTimeout      : 20000,
    isReadyTimeout      : 20000,
    runCore             : 'sequential'
});

harness.start(
    {
        group   : 'Unit Tests',
        preload         : [
            '../../../ext/build/ext-all-debug.js',
            '../../resources/locale/en.js'
        ],

        loaderPath      : {
            'MyApp'     : '../../app'
        },

        installLoaderInstrumentationHook    : true,

        requires        : [
            'MyApp.Globals',
        ],

        items   : [
            '01-unit-tests/010_globals.t.js'
        ] 
{
        group: 'UI Tests',
        items: [
            {
                group: 'Submodule List Screen',
                testClass: Siesta.Test.ListScreen,
                items: [
                    {
                        title           : 'Test Case A',
                        hostPageUrl     : myApp,
                        url             : listScreen + 'casea-list.webex.js'
                    },
                    {
                        title           : 'Test Case B',
                        hostPageUrl     : myApp,
                        url             : listScreen + 'caseb-list.webex.js'
                    },
                    {
                        title           : 'Test Case C',
                        hostPageUrl     : myApp,
                        url             : listScreen + 'casec-list.webex.js'
Base Class:
Class('Siesta.Test.ListScreen', {
    isa     : Siesta.Test.ExtJS,

    methods: {
    // Here is 2 sample method which is using by all other submodules through inheritance

    navigation: function (packageName, subModule, callback) {
        var t = this;

        t.chain(
            {waitForCQ: treeList, isReadyTimeout: 20000},

            function (next) {
                t.click('treelist[itemId=navigationTreeList]');
                next();

            },
            {click: '>> treelistitem[_text='+packageName+']'},
            {click: '>> treelistitem[_text='+subModule+']', desc: subModule+isDisplaying},
            {click: '#main-navigation-btn => .fa-navicon', desc: collapseDesc},

            function (next) {
                console.log('navigation func log');
                next();
            },

            callback
        );
    },
        grid: function (submoduleGrid, submoduleData, rootNumber, columnName, rowNumberer, callback) {
            var t = this;

            t.chain(
                function (next) {
                    console.log('grid func log');
                    next();
                },
                {waitForCQ: submoduleGrid +'[xtype='+ submoduleGrid +']', isReadyTimeout: 20000},
                {click: '#main-home #contentPanel ' + submoduleGrid +'> :ariadne-nth-child(1) tableview => .x-grid-item:nth-of-type(1) .x-grid-row-expander', desc: 'Clicks on Row Expander', isReadyTimeout: 20000},
                {click: '#main-home #contentPanel ' + submoduleGrid +' > :ariadne-nth-child(1) tableview => .x-grid-item:nth-of-type(1) .x-grid-checkcolumn', desc: 'Clicks on All checkbox ', isReadyTimeout: 20000},
                {click: '>> button[itemId=editBtn]', desc: 'Clicks on Edit button', isReadyTimeout: 20000},
                {waitForCQ: submoduleGrid +'[xtype='+ submoduleGrid +']', isReadyTimeout: 20000},
                {
                    action      : 'drag',
                    source      : '#main-home #contentPanel ' + submoduleData +'[xtype='+ submoduleData +'] => .x-title-icon',
                    to          : '.x-table-layout-cell'
                },
                {click: '>> button[text=Cancel]', timeout: 50000, desc: 'Cancel button works!', isReadyTimeout: 20000},
                {click: '#main-home #contentPanel ' + submoduleGrid +' > :ariadne-nth-child(1) tableview button(true):root('+rootNumber+') => .x-btn-wrap', timeout: 50000, desc: 'Clicks Menu button', isReadyTimeout: 20000},

                {click: '.x-menu-item-text:textEquals(Delete)', timeout: 50000, desc: 'Clicks Delete button', isReadyTimeout: 20000},
                {click: '>> button[text=No]', timeout: 50000, desc: 'No button works!', isReadyTimeout: 20000},
                {click: '#main-home #contentPanel ' + submoduleGrid +' > :ariadne-nth-child(1) tableview button(true):root('+rootNumber+') => .x-btn-wrap', timeout: 50000, desc: 'Clicks Menu button once again', isReadyTimeout: 20000},
                {moveCursorTo: '#main-home #contentPanel pagingtoolbar[name=pagingtoolbar] => .x-box-inner', timeout: 50000, desc: 'Scrolling Up to Down', isReadyTimeout: 20000},
                {moveCursorTo: '#main-home #contentPanel #normalHeaderCt ' + columnName + '=> .x-column-header-text-inner', timeout: 50000, desc: 'Scrolling Left to Right', isReadyTimeout: 20000},

                callback
            )
        },
Submodule:
describe('UI Testing: Submodule List Screen', function (t) {
    t.it('Should extend the Test Class and Login to App', function (t) {
       t.chain(
           {
                login: t.next
            }
        )
    });

    t.it('Should open: Submodule Grid', function (t) {
        t.chain(
            {
                navigation: [ 
                              'Definitions', //packageName
                              'Credit Card' //subModule
                            ]
            }
        )
    });

    t.it('Testing Upper Toolbar: Refresh, New, Print, Export to PDF, Export to Excel', function (t) {
        t.chain(
            {
                upperToolbar: 'ccarddata'
            }
        )
    });

    t.it('Testing Grid: Edit button, Menu button, Scrolling left > right, Clicking/selecting random row/cell', function (t) {
        t.chain(
            {
                grid: [
                    'ccardgrid', //submoduleGrid
                    'ccarddata', //submoduleData
                    '6',         //rootNumber
                    'crcardexpiredatecol[text=CC Expire Date]', //columnName
                    '49'            //rowNumberer
                ]
            }
        )
    });

    t.it('Testing Bottom Toolbar: Page field, Next/Prev Page buttons, Search combobox & Item selecting, Type in Search field, Clicks on Displaying progress bar', function (t) {
        t.chain(
            {
                bottomToolbar: t.next
            }
        )
    });
});

Post by nickolay »

Hi,

Please enable "stop on exception" mode in chrome debugger and provide more information about the exception ("TypeError: a.pseudos[d] is not a function") you experience. You can observe the values of variables in the debugger.

Hard to help you w/o additional information.

Post Reply