mercredi 27 juin 2018

Protractor: Else statement isn't working as expected

I'm trying to click on a link if it exists, if not it should add that corresponding link and then click on the same.

In below If loop, 'Else' condition is not getting executed if first condition is not satisfied. The same is working if its placed outside IF loop.

I'm confused.

Could anyone help me out in resolving this please ?

var ConfigLink = element.all(by.partialLinkText('Provide Configuration')).get(0);

        ConfigLink.isDisplayed().then(function(result) {
        if (result) {
                ConfigLink.click();
        } 

        else {
                element.all(by.css('input[name="checks"]')).get(0).click();
        }

        });

If the initial If condition fails , I want the script to execute the else part, but this is not working.

kindly suggest how this can be resolved Thank you

Aucun commentaire:

Enregistrer un commentaire