title: How to getText on an input in protractor
body: <p>In the documentation for protractor, I see the following example:</p>
  
  <pre><code>describe('by model', function() {
    it('should find an element by text input model', function() {
      var username = element(by.model('username'));
      username.clear();
      username.sendKeys('Jane Doe');
  
      var name = element(by.binding('username'));
  
      expect(name.getText()).toEqual('Jane Doe');
    });
  </code></pre>
  
  <p>What appears clear here is that you can use "by.model" to set values in an input box, but if you want to look at an input box and see what's in it, you need to use "by.binding".</p>
  
  <p>I have a set of code where (in summary) I do:</p>
  
  <pre><code>element(by.model('risk.name')).sendKeys('A value');
  expect(element(by.model('risk.name')).getText()).toEqual('A value');
  </code></pre>
  
  <p>(in my real code I save the entity then come back to it in edit mode, and I'm checking my value was actually saved.  But it still boils down to the same thing, and this sample code gives the same problem).</p>
  
  <p>This gives me an error:</p>
  
  <pre><code>Error: Expected '' to equal 'A value'.
  </code></pre>
  
  <p>In theory, following the example from the docs, I can instead do:</p>
  
  <pre><code>element(by.model('risk.name')).sendKeys('A value');
  expect(element(by.binding('risk.name)).getText()).toEqual('A value');
  </code></pre>
  
  <p>But the by.binding doesn't appear to like the fully qualified model, I get an error:  </p>
  
  <pre><code>Error: No element found using locator: by.binding("risk.name")
  </code></pre>
  
  <p>It does work (after a fashion) if I do:</p>
  
  <pre><code>element(by.model('risk.name')).sendKeys('A value');
  expect(element(by.binding('name')).getText()).toEqual('A value');
  </code></pre>
  
  <p>This finds an element, but also gives a warning that I have more than one element that matches 'name'.  And unfortunately the one it picks isn't the right one.  </p>
  
  <p>So, two questions:</p>
  
  <ol>
  <li>Should the by.model be able to return a getText(), or is there a design decision that it not do that and we need to use by.binding instead?</li>
  <li>Should I be able to use a fully qualified entity in the by.binding, or is there a design decision that by.binding doesn't like the full model name?  If so, what other qualifier can I use to select between my different bindings?</li>
  </ol>
  
  <p>EDIT:</p>
  
  <p>I have also tried the solution suggested by vdrulerz, I modified the code as follows:</p>
  
  <pre><code>element(by.model('risk.name')).getText().then(function(text) {
    console.log(text);
    expect(text).toEqual('A risk name');  
  });
  </code></pre>
  
  <p>The console.log is returning a blank value (not a promise or an object), and the expect fails giving the message:</p>
  
  <pre><code>Expected '' to equal 'A risk name'.
  </code></pre>
  
  <p>My understanding is that protractor already patches the expect to deal with the promise, so I feel that the underlying problem is the getText not working on a field identified via a model (I can successfully getText on labels and other widgets).</p>
  
  <p>I can also run the following code, using getAttribute rather than getText():</p>
  
  <pre><code>expect(element(by.model('risk.name')).getAttribute('autofocus')).toEqual('true');
  element(by.model('risk.name')).getAttribute('autofocus').then(function(text) {
    console.log(text);
    expect(text).toEqual('true');  
  });
  </code></pre>
  
  <p>The first part passes - the expect works.  The second part also works, suggesting that vdrulerz' syntax is also valid, and it logs 'true' to the console.  I think there is potentially a defect with getText?</p>