Sencha Test validate content of MessageBox

211 Views Asked by At

Does someone know how can you validate the text within a Messagebox using Sencha Test 2.1 ?

I'm successful in retrieving the actual messagebox like this:

ST.panel('messagebox').visible();

So I want to do something like:

ST.panel('messagebox').visible().expect('value').toEqual('Awesome, all went well!');

I've tried value, text, etc can't seem to find a property to use.

2

There are 2 best solutions below

2
On BEST ANSWER

Glad you figured out a solution. If you wanted to more of a direct assertion on the "html", you could do something like so:

it('should have the right html', function () {
    Ext.Msg.alert('Title', 'Awesome, all went well');

    ST.panel('messagebox')
      .gotoComponent('[cls=x-window-text]')
      .get('html')
      .and(function () {
          expect(this.future.data.html).toBe('Awesome, all went well');
      }); 
});

Or even more compact:

it('should have the right html', function () {
    Ext.Msg.alert('Title', 'Awesome, all went well');

    ST.panel('messagebox')
      .gotoComponent('[cls=x-window-text]')
      .expect('html')
      .toBe('Awesome, all went well'); 
});

http://docs.sencha.com/sencha_test/2.1.0/api/ST.future.Component.html#method-get

0
On

I did it like this: (this code was within a page object)

messageBox: function () {
        return ST.panel('messagebox').visible();
},

this.messageBox().element('[html="Awesome, all went well!"]').visible();

(and no, that's not really the content of the message box ;) )