If/else statements in test cases

Get help with testing, discuss unit testing strategies etc.
Post Reply
User avatar
berkancimen
Posts: 6
Joined: Fri Oct 26, 2018 4:24 pm

If/else statements in test cases

Post by berkancimen » Fri Nov 09, 2018 11:50 am

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 :

Code: Select all

messagebox[title=Application Update] 
. Here is clicking yes button:

Code: Select all

messagebox[title=Application Update] #yes => .x-btn-inner-default-small
.
I have to implement in this method:

Code: Select all

 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.

User avatar
mats
Core Developer
Core Developer
Posts: 13034
Joined: Sat Dec 19, 2009 11:41 pm
Location: Sweden
Contact:

Re: If/else statements in test cases

Post by mats » Fri Nov 09, 2018 1:09 pm

Just use a regular if statement?

Code: Select all

t.it('Test Case', function (t) {
                    t.chain(
                       
                      // HERE, I USE IF/ELSE statement.
                     if (foo) {
                         t.click('button:contains(Yes)', callback)
                     }
                     else {.... }
                       
                );
            });
Tired of debugging javascript errors in web applications? Try our new error logging service RootCause, or read more on the Sencha blog

@bryntum
Facebook
API documentation

User avatar
berkancimen
Posts: 6
Joined: Fri Oct 26, 2018 4:24 pm

Re: If/else statements in test cases

Post by berkancimen » Fri Nov 09, 2018 1:39 pm

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:

Code: Select all

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
                      }
                       
                );
      });

User avatar
mats
Core Developer
Core Developer
Posts: 13034
Joined: Sat Dec 19, 2009 11:41 pm
Location: Sweden
Contact:

Re: If/else statements in test cases

Post by mats » Fri Nov 09, 2018 1:47 pm

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.

Code: Select all

if (Ext.MessageBox.isVisible()) { ... } else { ... } 
Tired of debugging javascript errors in web applications? Try our new error logging service RootCause, or read more on the Sencha blog

@bryntum
Facebook
API documentation

User avatar
berkancimen
Posts: 6
Joined: Fri Oct 26, 2018 4:24 pm

Re: If/else statements in test cases

Post by berkancimen » Fri Nov 09, 2018 2:49 pm

Ok, thank you.

User avatar
nickolay
Core Developer
Core Developer
Posts: 3276
Joined: Mon May 16, 2011 10:48 am

Re: If/else statements in test cases

Post by nickolay » Mon Nov 12, 2018 9:32 am

See also this method: https://www.bryntum.com/docs/siesta/#!/ ... thod-query, if it returns empty array, then there's no target to click.
We offer training in both Ext JS and our products, read more here.
Read the API documentation

Post Reply