Get help with testing, discuss unit testing strategies etc.


Post by sqatester123 »

Hello,

Is there a way to wait for a t.chain() to finish before starting execution of another?

Take this code for example.
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]"
            }
        )
        t.chain(
            {
                action: "click",
                target: "#main-nav-bar button[text=Alarms and Events] => .x-btn-inner-default-toolbar-small"
            }
        )
    }
)
The problem I'm having is that the second one starts before the first can finish so the next button isn't ready by the time the chain times out.

I know that I could combine the chains above, but this is a simplified example.

Post by mats »

Wrap the two chains in a 't.it(' statement, and they will run in sequence.

Post by sqatester123 »

I cannot wrap them together unfortunately. The two chains are created in different functions. I need to know that he first one has finished before I can start the second.

Post by mats »

I meant:
    StartTest(function(t) {
t.it('Do something here...', 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]"
                }
            )
});

t.it('Do something after here...', function(t) {
            t.chain(
                {
                    action: "click",
                    target: "#main-nav-bar button[text=Alarms and Events] => .x-btn-inner-default-toolbar-small"
                }
            )
        }
    )

})

Post by nickolay »

You can also wrap the 2nd in the callback, and put this callback as the last step of the 1st chain.

Post Reply