jasmine - Protractor IF condition was executed first before IT -


is there way ensure it executed first before if condition located below it?

sample code:

it('should click ' + strname + ' list', function() {     exports.waitforelementdisp(10, global.elmgravitypanel, false);     browser.sleep(2000).then(function() {         element(by.css('[cellvalue="' + strname + '"]')).click();         element(by.id('uniqueid')).gettext().then(function(tmptext) {             global.tempobject.ispresent = false;             if (tmptext == strname) {                 global.tempobject.ispresent = true;             }         });     }); });  if (global.tempobject.ispresent == true) {     it('should click settings icon', function() {         global.elmsettingbtn.click();     });      it... } 

currently, global.tempobject.ispresent set null , protractor did not go inside if though set true inside first it.

because 'if' executed on file parsing. suggest try this:

it(`should click ${strname} list`, function () {     exports.waitforelementdisp(10, global.elmgravitypanel, false);     browser.sleep(2000)     $(`[cellvalue="${strname}"]`).click();     $('#uniqueid').gettext().then(function (tmptext) {         global.tempobject.ispresent = false;         if (tmptext == strname) {             global.tempobject.ispresent = true;         }     });  });  /**  *   * @param condition boolean condition check  * @param suiteortest function, contains scheduling of tests.  */ function runif(condition, suiteortest) {     if (condition) {         return suiteortest     } else {         console.log('skipping execution')     } }  describe('conditional execution', () => {     it('1', function () {         global.elmsettingbtn.click();     });      it('this test condition', runif(process.env.is_linux, ()=> {         // other test         global.elmsettingbtn.click();     })) })) 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -