Page 1 of 1

If/else statements in test cases

Posted: Fri Nov 09, 2018 11:50 am
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.

Re: If/else statements in test cases

Posted: Fri Nov 09, 2018 1:09 pm
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 {.... }
                       
                );
            });

Re: If/else statements in test cases

Posted: Fri Nov 09, 2018 1:39 pm
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
                      }
                       
                );
      });

Re: If/else statements in test cases

Posted: Fri Nov 09, 2018 1:47 pm
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 { ... } 

Re: If/else statements in test cases

Posted: Fri Nov 09, 2018 2:49 pm
by berkancimen
Ok, thank you.

Re: If/else statements in test cases

Posted: Mon Nov 12, 2018 9:32 am
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.