Page 2 of 2

Re: ReferenceError: Ext is not defined

Posted: Fri Apr 28, 2017 4:19 pm
by sqatester123
Tried adding the updated waitFor and got the same TypeError.

Where should I add the waitForAppReady flag?

Re: ReferenceError: Ext is not defined

Posted: Fri Apr 28, 2017 4:27 pm
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.

Re: ReferenceError: Ext is not defined

Posted: Fri Apr 28, 2017 4:32 pm
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?

Re: ReferenceError: Ext is not defined

Posted: Fri Apr 28, 2017 4:38 pm
by nickolay
Sure. Check this guide for the "login" guide: https://www.bryntum.com/docs/siesta/#!/ ... _touch_app

Re: ReferenceError: Ext is not defined

Posted: Fri Apr 28, 2017 4:46 pm
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);
    }
)

Re: ReferenceError: Ext is not defined

Posted: Fri Apr 28, 2017 8:51 pm
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.

Re: ReferenceError: Ext is not defined

Posted: Fri Apr 28, 2017 9:05 pm
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?

Re: ReferenceError: Ext is not defined

Posted: Sat Apr 29, 2017 12:09 am
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"
                // }
            )
        }
    )