PDA

View Full Version : [FIXED] Message Box timeout problem clicking yes/no button



tosky
14 Nov 2016, 2:44 AM
Hi,

there is a problem clicking yes/no button inside a message box in Sencha. I receive a strange timeout problem in test results, even if the button is visually clicked correctly.


The test is as follows:

it('should click message box button button', function() {

ST.component('messagebox')
.rendered()
.and(function(el) {
ST.component('messagebox button[text="No"]')
.rendered()
.click();
})
})
This is the error in Sencha Studio:


Timeout waiting for target (messagebox button[text="No"]) to be visible for click


The message box inside my code:

Ext.Msg.confirm('Test message box', 'Click yes or no',

function (choice) {
if (choice === 'yes') {
console.log('clicked yes')
}
else
console.log('no')
});

This is crucial even if this can appear a trivial problem, since clicking yes triggers a series of actions that cannot be triggered in other ways.

We tried almost every technique, even clicking using XPath but the error is the same. Last but not least, this problems seems to be not deterministic. (Sometimes it works and sometimes not)

Any suggestion? Can be a problem with the used Webdrivers?

Thanks,
Luigi

vojtech.cerveny
14 Nov 2016, 6:13 AM
Hi Luigi,
I guess that you use SenchaTest 1.0.3, right? It has a problem with components, which disappear after clicking. It is fixed in ST 2.0

We have "hack" for it - normal click in ST 1.0.3 is composed from mousedown, mouseup, click, so it throws error if component disappears after mouseup.

But you can use this:

function ghostClick(loc) {

var fieldForPlay = [
{type: "click", target: loc, detail: 1}
];

ST.play(fieldForPlay);
}

it('should click message box button button', function() {
ST.component('messagebox')
.rendered();
// you can put it into and function, but it is unnecessary.
ghostClick('messagebox button[text="No"]')
});

Feel free to contact me any time.
Vojtěch Červený

tosky
14 Nov 2016, 6:41 AM
Hi Vojtěch,

I tried the 2.0 EA version but with no success. Using the solution you posted above it triggers a click but without the correct focus, so messagebox is not closed.

This is my code where I just added explicit focus on the component.


it('should click message box button button', function() {
ST.component('messagebox button[text="Yes"]')
.focus()
.focused()
.and(function () {

ghostClick('messagebox button[text="Yes"]');
});
});

vojtech.cerveny
14 Nov 2016, 7:00 AM
Hi,
I tried ST2.0.0.269 and this code works for me. I creates your messagebox and then I am able to click on button and box disappears. What version ExtJS do you use?



describe("TEST", function() {
beforeAll(function(){
Ext.Msg.confirm('Test message box', 'Click yes or no',
function (choice) {
if (choice === 'yes') {
console.log('clicked yes')
}
else
console.log('no')
});
});

it("should pass", function() {
ST.component('messagebox button[text="Yes"]')
.click();
});
});

tosky
15 Nov 2016, 12:02 AM
The Extjs version I use is 6.0.1

Anyway, I tried again with Sencha Test 2 EA and it seems to work! But I can see that this EA version still has some problems so I would like to fix it on the previous version. Could you suggest any other technique for confirm buttons click?

This is a list of main problems encountered with version 2:

- stc command line error in test results,
- synchronization error in setup/teardown method that works with 1.0.3,
- stop button inside GUI is not clickable while running tests

Is there a release roadmap for a full working release of Sencha Test 2?

Thanks a lot,
Luigi

tosky
17 Nov 2016, 3:04 AM
For anyone interested I solved this way




ST.component('messagebox')
.and(function(el) {
expect(el.isVisible()).toBeTruthy();

el.msgButtons.yes.handler.call(el, me.msgButtons.yes);

expect(el.isVisible()).toBeFalsy();
}