Get help with testing, discuss unit testing strategies etc.


Post by jflowers45 »

I've had success doing waitForComponentQuery with a function value as follows.
{ waitForCQ: 
function() { return "mycomponent[title^=Edit id - " + some_id_calculated_earlier + "]"}, 
desc: "Verify Editor Opened to appropriate record" 
}
I confirmed this was a supported approach in this thread - viewtopic.php?f=20&t=9162

I'd like to do the same thing with a type: action. It would be something like this:
{ type: function()  { return some_string_calculated_earlier;},  target: "#filters menu > :nth-child(4) => .x-form-text" },
I'm not getting the results I expect. Instead, it actually writes the function body into the text field. I can work around it like this, but it's more verbose than I'd like.
function(next) {
        var els = this.compositeQuery('#filters menu > :nth-child(4) => .x-form-text');
        if (els.length > 0) {
          var txtField = els[0];
          txtField.value = some_string_calculated_earlier;
          next();
        }
 },
Is there a good compact syntax I can use? Thanks!

-Joe

Post by nickolay »

In "type" action, returning value from function supported only for "target" property, not for the text being typed. You could just use "t.type()" method as well (wrapped in the function step).

Post by jflowers45 »

perfect! thanks for your prompt response. this worked like a charm
function(next) {
        t.type('#filters menu > :nth-child(4) => .x-form-text',  some_string_calculated_earlier );
        next();
      },

Post by nickolay »

Yw! Small note - the "next" callback here is better to provided to `type` method (otherwise chain will continue immediately, while typing is still in process)

Post by jflowers45 »

Thank you for pointing that out, it would have tripped me up! I've updated it to be
function(next) {  //type in the ID
	t.type( '#filters menu > :nth-child(4) => .x-form-text', some_string_calculated_earlier, function() {
	  next();
	});
}

Post Reply