Get help with testing, discuss unit testing strategies etc.


Post by sqatester123 »

Tried adding the updated waitFor and got the same TypeError.

Where should I add the waitForAppReady flag?

Post by nickolay »

In the test descriptor config or in the harness config.

Ok, make sure the test page actually contains Ext.ComponentQuery. You can switch to context of different iframes in Chrome debugger.

Post by sqatester123 »

Okay, I think I found the problem. ext-all-debug.js isn't loaded until after the login page of our app. In theory should I be able to execute component queries after logged in?

Post by nickolay »

Sure. Check this guide for the "login" guide: https://www.bryntum.com/docs/siesta/#!/ ... _touch_app

Post by sqatester123 »

I'm able to login using the following test. But I still get a type error when trying to do the component query. The test case doesn't start the error occurs before the login occurs.
StartTest(function(t) {
    t.chain(
            {
                action: "type",
                target: "input[name=j_username]",
                text: "<user>"
            },
            {
                action: "type",
                target: "input[name=j_password]",
                text: "<password>"
            },
            {
                action: "click",
                target: "button[type=submit]"
            },
            { 
                waitFor : function() { return t.global.Ext && t.global.Ext.ComponentQuery; }
            }
            // {
            //     action: "click",
            //     target: "button[id=button-1057] => .x-btn-button"
            // },
            // {
            //     action: "rightclick",
            //     target: "treeview[id=treeview-1125] => .x-tree-view"
            // }
        )
    
    var result= t.global.Ext.ComponentQuery.query("treeview[id=treeview-1125]")[0].id;
    t.diag(result);

    t.waitForMs(30000);
    }
)

Post by nickolay »

Need to wait for the page load after you initiate the login with "click": https://www.bryntum.com/docs/siesta/#!/ ... orPageLoad

Also see https://www.bryntum.com/docs/siesta/#!/ ... fg-trigger to understand the concept of race condition.

Post by sqatester123 »

I added the waitFor page load and that seems to work, but I am still unable to run my component query. It seems the component query lines are run while the t.chain code is run. Is there a way I can wait until the t.chain functions are completed before moving on?

Post by mats »

Yes, need to use the 'chain' syntax:
    StartTest(function(t) {
        t.chain(
                {
                    action: "type",
                    target: "input[name=j_username]",
                    text: "<user>"
                },
                {
                    action: "type",
                    target: "input[name=j_password]",
                    text: "<password>"
                },
                {
                    action: "click",
                    target: "button[type=submit]"
                },
                {
                    waitFor : function() { return t.global.Ext && t.global.Ext.ComponentQuery; }
                },

               function() {

          
                   var result= t.global.Ext.ComponentQuery.query("treeview[id=treeview-1125]")[0].id;
                   t.diag(result);


                }
                // {
                //     action: "click",
                //     target: "button[id=button-1057] => .x-btn-button"
                // },
                // {
                //     action: "rightclick",
                //     target: "treeview[id=treeview-1125] => .x-tree-view"
                // }
            )
        }
    )

Post Reply