title: How to get only text from element - Protractor Javascript
body: <p>I am trying to get raw text only from a html element. For example:</p>
  
  <pre><code>&lt;h1&gt;This is a &lt;br&gt; Test&lt;/h1&gt;
  </code></pre>
  
  <p>I want to be able to get the text inside <code>&lt;h1&gt;</code> minus the <code>&lt;br&gt;</code>....</p>
  
  <p><code>this is a Test</code></p>
  
  <p>I have tried:</p>
  
  <p><code>browser.driver.findElement(By.tagName('h1')).getAttribute('textContent');</code></p>
  
  <p><code>browser.driver.findElement(By.tagName('h1')).getAttribute('innerHTML');</code></p>
  
  <p><code>browser.executeScript("return arguments[0].innerHTML;", element(locator));</code></p>
  
  <p>I don't see any reason why <code>getAttribute('textContent')</code> isn't working, I think that would be the easiest way to get the raw text.</p>
  
  <p>I know there have been some breaking changes with protractor for angular over the last few releases, that led me to use <code>browser.executeScript</code>.</p>
  
  <p><strong>Update</strong></p>
  
  <p>Please only post a solution if you have directly used it with protractor.</p>