title: org.openqa.selenium.InvalidSelectorException - [object Text]. It should be an element
body: <p>I am trying to retrieve values email1, Email2, and HT from following using XPATH</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;table class="table-striped table-bordered" cellspacing="0" style="table-layout: fixed; width: 100%;"&gt;
  &lt;colgroup&gt;
  &lt;tbody&gt;
  &lt;tr class="GPEHNV5BGF GPEHNV5BNF" __gwt_subrow="0" __gwt_row="0"&gt;
  &lt;td class="GPEHNV5BFF GPEHNV5BHF GPEHNV5BIF GPEHNV5BOF"&gt;
  &lt;div __gwt_cell="cell-gwt-uid-515" style="outline-style:none;"&gt;email1&lt;/div&gt;
  &lt;/td&gt;
  &lt;td class="GPEHNV5BFF GPEHNV5BHF GPEHNV5BOF"&gt;
  &lt;td class="GPEHNV5BFF GPEHNV5BHF GPEHNV5BCG GPEHNV5BOF"&gt;
  &lt;/tr&gt;
  &lt;tr class="GPEHNV5BFG" __gwt_subrow="0" __gwt_row="1"&gt;
  &lt;td class="GPEHNV5BFF GPEHNV5BGG GPEHNV5BIF"&gt;
  &lt;div __gwt_cell="cell-gwt-uid-515" style="outline-style:none;"&gt;Email2&lt;/div&gt;
  &lt;/td&gt;
  &lt;td class="GPEHNV5BFF GPEHNV5BGG"&gt;
  &lt;td class="GPEHNV5BFF GPEHNV5BGG GPEHNV5BCG"&gt;
  &lt;/tr&gt;
  &lt;tr class="GPEHNV5BGF" __gwt_subrow="0" __gwt_row="2"&gt;
  &lt;td class="GPEHNV5BFF GPEHNV5BHF GPEHNV5BIF"&gt;
  &lt;div __gwt_cell="cell-gwt-uid-515" style="outline-style:none;"&gt;HT&lt;/div&gt;
  &lt;/td&gt;
  &lt;td class="GPEHNV5BFF GPEHNV5BHF"&gt;
  &lt;td class="GPEHNV5BFF GPEHNV5BHF GPEHNV5BCG"&gt;
  &lt;/tr&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Following is my code with XPATH:</p>
  
  <pre><code>int rows=driver.findElements(By.xpath("//table[@class='table-striped table-bordered']/tbody/tr")).size();
          List&lt;String&gt; EmailConnectorRoutineList= new ArrayList&lt;String&gt;();
          for(int i=0;i&lt;=rows;i++){
              String referenceName=null;
              referenceName=driver.findElement(By.xpath("//table[@class='table-striped table-bordered']/tbody/tr[@ __gwt_row='"+i+"']/td[1]/div/text()")).getText();
  
              //referenceName=refName.getText();
              EmailConnectorRoutineList.add(referenceName);
          }
  </code></pre>
  
  <p>I tried following XPATH as well</p>
  
  <pre><code>//table[@class='table-striped table-bordered']/tbody/tr[@ __gwt_row='"+i+"']/td[1]/div/text()")).getAttribute("value");
  </code></pre>
  
  <p>Showing following error:</p>
  
  <blockquote>
    <p>org.openqa.selenium.InvalidSelectorException: The given selector //table[@class='table-striped table-bordered']/tbody/tr[@ __gwt_row='0']/td[1]/div/text() is either invalid or does not result in a WebElement. The following error occurred:
    InvalidSelectorError: The result of the xpath expression "//table[@class='table-striped table-bordered']/tbody/tr[@ __gwt_row='0']/td[1]/div/text()" is: [object Text]. It should be an element.</p>
  </blockquote>