title: AngularJS + Protractor How to select Dropdown option based on its text not value
body: <p>I want to click on item by it's text and not by it's value from dropdown box.</p>
  
  <p>i found this great post : <a href="https://coderwall.com/p/tjx5zg" rel="noreferrer">https://coderwall.com/p/tjx5zg</a> but it doesn't work as expected, the search continue forever after match was found and it is not clicking the item,</p>
  
  <p>if someone have better example (a working one) or can fix this code and make it work, </p>
  
  <p>i will apperciate.</p>
  
  <p>This is the code Dan Haller from the post used (all rights reserved to him)</p>
  
  <pre><code>function selectOption(selector, item){
      var selectList, desiredOption;
  
      selectList = this.findElement(selector);
      selectList.click();
  
      selectList.findElements(protractor.By.tagName('option'))
          .then(function findMatchingOption(options){
              options.some(function(option){
                  option.getText().then(function doesOptionMatch(text){
                      if (item === text){
                          desiredOption = option;
                          return true;
                      }
                  });
              });
          })
          .then(function clickOption(){
              if (desiredOption){
                  desiredOption.click();
              }
          });
      }
  </code></pre>
  
  <p>This is a select item function that I can use like this:</p>
  
  <pre><code>var browser = protractor.getInstance();
  browser.selectOption = selectOption.bind(browser);
  browser.selectOption(protractor.By.id('my-dropdown'), 'My Value');
  </code></pre>