Get help with testing, discuss unit testing strategies etc.


Post by berkancimen »

I need an if/else statement for my test case. Here is the scenario; if this window Image appears click yes, if not do something else. This window appears sometimes. It is the value of target in event recorder :
messagebox[title=Application Update] 
. Here is clicking yes button:
messagebox[title=Application Update] #yes => .x-btn-inner-default-small
.
I have to implement in this method:
 func: function (callback) {
            let t = this;

            t.it('Test Case', function (t) {
                    t.chain(
                        
                  // HERE, I NEED TO USE IF/ELSE statement.

                        callback
                );
            });
        },

Any help would be appreciated.

Post by mats »

Just use a regular if statement?
t.it('Test Case', function (t) {
                    t.chain(
                       
                      // HERE, I USE IF/ELSE statement.
                     if (foo) {
                         t.click('button:contains(Yes)', callback)
                     }
                     else {.... }
                       
                );
            });

Post by berkancimen »

I am newbie on Javascript and Siesta so I need more information. I will use if statement for if window appeared or not. I asked wrong question actually. I need that statement which states window appeared or not?

Btw, I am using this system for if/else:
t.it('Test Case', function (t) {
                t.chain(
                   function (next) { 
                     if (foo) 
                         t.chain {
                              t.click('button:contains(Yes)', callback)
                              next
                     };
                     else 
                          t.chain {
                               ............ 
                               next
                      }
                       
                );
      });

Post by mats »

Ok, we strongly recommend you read up on basic JS / CSS and study our Siesta API before authoring tests.

Start here for CSS: https://developer.mozilla.org/en-US/doc ... ion_to_CSS

If you want to detect a certain state of your app without querying your app state, then you'd have to use some CSS / DOM querying or the Ext JS API.
if (Ext.MessageBox.isVisible()) { ... } else { ... } 

Post by berkancimen »

Ok, thank you.

Post by nickolay »

See also this method: https://www.bryntum.com/docs/siesta/#!/ ... thod-query, if it returns empty array, then there's no target to click.

Post Reply