Get help with testing, discuss unit testing strategies etc.


Post by arielalvarez88 »

Hi guys, thank you for this amazing product.

I am having trouble with the event recorder. I record some steps, then I try to replay them (or put the generated code in the actual test file and run the test), and some steps fails.

Examples:

1) I generated this code:
describe("New recording...", function(t) {
    t.chain(
        { moveCursorTo : "#app-mainview #my-grid gridcolumn[name=State] => .x-column-header-inner", offset : [11,5] },

        { click : "button[text=New] => .x-btn-inner-center" },

        { moveCursorTo : ">>#ext-gen1026", offset : [113,3] },

        { moveCursorTo : ">>#ext-gen1028", offset : [104,2] },

        { moveCursorTo : ">>#ext-gen1029", offset : [94,9] },

        { moveCursorTo : ">>#ext-gen1027", offset : [91,1] },

        { click : "#ext-gen1027 => .x-menu-item-text" },

        { mousedown : "textfield[fieldLabel=Project] => .x-form-text", offset : [115,22] },

        { mouseup : [227,199] },

        { type : "test", target : "textfield[fieldLabel=Project] => .x-form-text" },

        { mousedown : "field-profile-profilepicker[fieldLabel=Team] => .x-boxselect-input :contains(Which people are in this proje)", offset : [22,7] },

        { mouseup : [234,244] },

        { mousedown : ".field-bound-list:nth-of-type(11) :textEquals(Rodrigo Hammerly)", offset : [45,12] },

        { mouseup : [248,301] },

        { mousedown : ".field-bound-list:nth-of-type(11) :textEquals(Richard Croucher)", offset : [40,15] },

        { mouseup : [243,279] },

        { mousedown : "textfield(true):root(58) => .x-form-item-label", offset : [124,14] },

        { mouseup : [176,285] },

        { type : "test", target : "textfield(true):root(58) => .x-form-text" },

        { mousedown : "field-profile-profilepicker[fieldLabel=Manager] => .x-boxselect-input :contains(Who will be the manager for th)", offset : [40,16] },

        { mouseup : [252,386] },

        { mousedown : ".field-bound-list:nth-of-type(14) :textEquals(Rodrigo Hammerly)", offset : [63,13] },

        { mouseup : [266,435] },

        { mousedown : "datefield[fieldLabel=Estimated Start Date] => .x-form-text", offset : [37,13] },

        { mouseup : [329,510] },

        { mousedown : ".x-datepicker:nth-of-type(15) .x-datepicker-date:textEquals(22)", offset : [22,11] },

        { mouseup : [437,672] },

        { click : "datefield[fieldLabel=Estimated End Date] => .x-trigger-index-0" },

        { click : ".x-datepicker:nth-of-type(16) .x-datepicker-next" },

        { click : ".x-datepicker:nth-of-type(16) .x-datepicker-next" },

        { mousedown : "[title='April 13\, 2018'] .x-datepicker-date", offset : [7,16] },

        { mouseup : [452,675] },

        { mousedown : "durationfield[inputType=text]:ariadne-nth-child(4) => .x-form-text", offset : [73,16] },

        { mouseup : [360,604] },

        { type : "1 hr", target : "durationfield[inputType=text]:ariadne-nth-child(4) => .x-form-text" },

        { click : "button(true):root(149) => .x-btn-icon-el" }
    );
});

After refreshing and playing from the event recorder it failed here -> .field-bound-list:nth-of-type(14) :textEquals(Rodrigo Hammerly) (step 22)

After puting that code in the actual test file it failed and runing the test, it failed here ->

.field-bound-list:nth-of-type(11) :textEquals(Rodrigo Hammerly) (step 13)

After fixing these more will come up, I was wondering what to do.

2) A specially troublesome case is selecting a date from 2 datefields, where I click the arrow for next month in both datefields. This is the generated code:

    t.chain(
        { click : "datefield[fieldLabel=Start Date] => .x-form-text" },

        { click : ".x-datepicker:nth-of-type(15) .x-datepicker-next" },

        { click : ".x-datepicker:nth-of-type(15) [title='March 07\, 2018'] .x-datepicker-date" },

        { click : "datefield[fieldLabel=End Date] => .x-form-text" },

        { dblclick : ".x-datepicker:nth-of-type(16) .x-datepicker-next" },

        { mousedown : "[title='April 20\, 2018'] .x-datepicker-date", offset : [14,13] },

        { mouseup : [459,697] }
    );
I didn't even refresh the page and it fails at step 3 when replying in event recorder.

Am I doing something wrong? Is there a way to avoid this without manually put ids to everything and changing the generated code with the correct fixed ids?

Post by nickolay »

Hi,
thank you for this amazing product.
Thanks!

The query finder does its best, if the element has nothing specific, how it can be distinguished among the other 15 similar elements? It falls back to :nth-of-type only when there's no specific css classes etc. The best way to make queries robust is to add ids or some other specific properties, like css class.

What is your Ext version? I see query finder finds #ext-gen1029 as an id query, which should not happen for auto-generated ids. You can suppress this with this config https://www.bryntum.com/docs/siesta/#!/ ... mElementId which can be provided as part of this config https://www.bryntum.com/docs/siesta/#!/ ... rderConfig of the harness.

Post by arielalvarez88 »

My version of ExtJS is 4.2.2, I will try that config and see what happens. Thank you.

Post Reply