title: Protractor promise return string to compare with value
body: <p>i am using protractor to test AngularJS website. I need some protractor function to return a value of promise to continue in my code right way. </p>
  
  <p>Especially, i need to get value from input and compare it with some constant. Tried this way:</p>
  
  <pre><code>    var p1 = new Promise(function (resolve, reject) {
  
          if (element(by.id('policyNumber')).getAttribute('value') == parameter.getJinyDotazParams().attributes.policyNumber) {
              resolve("Success");
          } else {
              reject("Error");
          }
      });
  
      p1.then(function (value) {
          console.log(value + 'yaaay'); // Success!
      }, function (reason) {
          console.log(reason + 'Q_Q'); // Error!
      });
  </code></pre>
  
  <p>For example, with boolean return everything work:</p>
  
  <pre><code>    var p1 = new Promise(function (resolve, reject) {
  
          if (element(by.id('policyNumber')).isDisplayed()) {
              resolve("Success");
          } else {
              reject("Error");
          }
  
          //resolve("Success!");
          // or
          //reject("Error!");
      });
  
      p1.then(function (value) {
          console.log(value + 'yaaay'); // Success!
      }, function (reason) {
          console.log(reason + 'Q_Q'); // Error!
      });
  </code></pre>