title: How to get Text from H1 Tag which has no arguments in Web Driver?
body: <pre><code>&lt;html&gt;
    &lt;head&gt;...&lt;/head&gt;
    &lt;body&gt;
      &lt;h1&gt;Phonetic Translator&lt;/h1&gt;
      &lt;br&gt;
      &lt;link rel="stylesheet" href="/style.css" type="text/css"&gt;
      &lt;title&gt;electRa Phonetic Translator&lt;/title&gt;
      &lt;p&gt;Today's password is:&lt;/p&gt;
      &lt;h1&gt;
        MQQJXJLCQZ
        &lt;hr width="80%"&gt;
      &lt;/h1&gt;
      &lt;p&gt;The phonetic translation is:&lt;/p&gt;
      &lt;h3&gt;
        ...
      &lt;/h3&gt;
      ...
    &lt;/body&gt;
  &lt;html&gt;
  </code></pre>
  
  <p>Hi,</p>
  
  <p>I want to get the text <code>MQQJXJLCQZ</code>. As there are two H1 tags after Body. I have used XPath to get the text value but unfortunately I am getting the error message <code>Type mismatch: cannot convert from String to WebElement</code></p>
  
  <p>The code I have written is :</p>
  
  <pre><code>    String PasswordxPath = "/html/body/h1[2]/text()";
      WebElement H1Element = driver.findElement(By.xpath(PasswordxPath));
      WebElement getPassword = H1Element.getText();
  </code></pre>
  
  <p>Please, can someone correct this code or suggest another way to get the text Value ?</p>
  
  <p>Thanks,</p>
  
  <p><strong>UPDATE1</strong></p>
  
  <p>I have used string to get the text value, but now i am unable to put this value in the form using sendKeys. Error log as below: </p>
  
  <blockquote>
    <p>Element info: {Using=xpath, value=/html/body/h1[2]/text()} at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Nativ‌​‌​e Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknow‌​‌​n Source)</p>
  </blockquote>