title: How do I get a Paragraph Element with Html Unit and Xpath
body: <p>Hi I´m fairly new to HtmlUnit, I got a project where I want to fetch some information from a side and till now everything went smooth finding elements via name or id. But I was unable to get the following Paragraph Element.</p>
  
  <pre><code>&lt;iframe id="content_ifr" frameborder="0" src="javascript:""" allowtransparency="true" title=".." style="width: 100%; height: 307px; display: block;"&gt;
  &lt;!DOCTYPE &gt;
  &lt;html&gt;
  &lt;head&gt; ... &lt;/head&gt;
  &lt;body id="tinymce" class="mceContentBody content post-type-coupon wp-editor" contenteditable="true" onload="window.parent.tinyMCE.get('content').onLoad.dispatch();" dir="ltr"&gt;
  &lt;p&gt;------ Text from the Element i want to get ------- &lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  &lt;/iframe&gt;
  </code></pre>
  
  <p>I tried already:</p>
  
  <pre><code>side.getByXPath("//html/body/p");// zero elements
  side.getByXpath("//p");// 27 element but wrong.
  side.getByXpath("//body");// 1 element but wrong.
  side.getByXpath("//html");// 1 element but wrong.
  side.getByXpath("//html/body/div[3]/div[3]/div[2]/div/div[4]/form/div/div/div/div[2]/div/div[2]/span/table/tbody/tr[2]/td/iframe"); // Zero elements found
  </code></pre>
  
  <p>I checked all elements the Code found with this:</p>
  
  <pre><code>List&lt;?&gt; list =gPage.getByXPath("//p");
      for(Object x:list){
          HtmlElement y=(HtmlElement) x;
          if(y.asXml().contains("Keyword")||y.asText().contains("Keyword")){
          System.out.println(y.asText());
          }
  </code></pre>
  
  <p>So in conclusion I couldn´t find the Paragraph Element by his Text. Could you help me find the Paragraph element, so that I´m able to read and write from/to it?</p>
  
  <pre><code>        //Initialize WebClient
          final WebClient webClient= new WebClient(BrowserVersion.FIREFOX_24);
          webClient.getCookieManager().setCookiesEnabled(true);
          webClient.getOptions().setThrowExceptionOnScriptError(false);
          webClient.getOptions().setCssEnabled(false);
          webClient.getOptions().setUseInsecureSSL(true);
          webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
          webClient.waitForBackgroundJavaScript(10000);
  
          //Perform a login.
          final HtmlPage page = webClient.getPage("");        
          final HtmlForm form = page.getForms().get(1);
          final HtmlTextInput username = form.getInputByName("log");
          final HtmlPasswordInput pw = form.getInputByName("pwd");
          username.setValueAttribute("");
          pw.setValueAttribute("");
          @SuppressWarnings("unused")
          HtmlPage page2 =  (HtmlPage) form.getButtonByName("login").click();
  
          //Get gutscheinPage
          HtmlPage gutscheinPage= webClient.getPage("");
  
          //Change Content of Textfield
          HtmlPage pageFrame = (HtmlPage) gutscheinPage.getFrames().get(0).getEnclosedPage();
          HtmlElement body =pageFrame.getBody();
          HtmlParagraph p =(HtmlParagraph) body.getByXPath("//p").get(0);
          p.setTextContent(text);
  </code></pre>
  
  <p>Done: Change the webClient default Browser and wait for Jscript,use getFrames, find the body and use the now easy XPath to provide me with my Paragraph Element.</p>
  
  <p>I really hope someone will find this helpfull for their own work.</p>
  
  <p>Thanks for every answer.</p>