0

There are two elements on the GUI, depending on the context only a single is visible.

Therefore, i like to use a helper function that gives the the Protractor element of the currently visible element.

However, i have to wait until the promise is resolved since everything is asynchronous.

    function () {
      var result;

      var controlA = $('controlA');
      var controlB = $('controlB');

      listControl.isDisplayed().then(function (isVisible) {
        result = isVisible;
        // STEP X
      });
      // WAIT HERE UNTIL STEP X is done

      return result ? controlA : controlB;
    };

Clarification: I do NOT want to wait until the control is getting visible.

geskill
  • 307
  • 2
  • 8

1 Answers1

0

You can directly return the control inside the isDisplayed() promise itself.Look at below example code.

   function () {
      var result;

      var controlA = $('controlA');
      var controlB = $('controlB');

     return listControl.isDisplayed().then(function (isVisible) {
        return isVisible ? controlA : controlB;
      });
};
Sudharsan Selvaraj
  • 4,792
  • 3
  • 14
  • 22