title: HtmlUnit - Selecting Forms, CheckBoxes, TextFields, and Submit Buttons
body: <p>I have been messing around with HtmlUnit for a little bit and particularly this website because it has quite a few features that I wanted to get used to. I have posted about it before but that was mainly for grabbing information off the site which ended up successful. Now I am wanting to fill in a form and submit it. </p>
  
  <p><strong>Current Test Code:</strong></p>
  
  <pre><code>def url = "http://www.hidemyass.com/proxy-list/"
  
  
  client = new WebClient(BrowserVersion.FIREFOX_3)
  client.javaScriptEnabled = false
  
  page = client.getPage(url)
  form = page.getFormByName("proxyform")
  
  //get portInputField and set value
  portField = form.getInputByName("p")
  portField.setValueAttribute("80")
  
  //select checkbox 1 &amp; 2 from anonymity level
  //click "Update Results"
  //get new page url
  //grab information
  //save
  </code></pre>
  
  <p>The section commented out is where I am unsure of what to do. I went ahead and attempted but would like to ask for input on what I should be doing.</p>
  
  <p><strong>Attempt:</strong> </p>
  
  <pre><code>def url = "http://www.hidemyass.com/proxy-list/"
  
  page = client.getPage(url)
  
  portField = page.getHtmlElementById("ports").setValueAttribute("80")
  
  submitButton = page.getByXPath("/html/body//form//input[@type='image']")
  page2 = submitButton.get(0).click()
  
  println page2    
  </code></pre>
  
  <p>The snippet above prints out: <strong>HtmlPage(http://www.hidemyass.com/proxy-list/search-1)@17168934</strong></p>
  
  <p>I'm looking to get a new page where I can then parse the information from the search. Any ideas?</p>
  
  <p>I don't believe the language I am using should make too much of a difference; however, I am using Groovy.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I managed to get what I wanted but it returns like so:</p>
  
  <pre><code>HtmlPage(http://www.hidemyass.com/proxy-list/search-1)@23713629
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;td&gt;109.123.00.00&lt;/td&gt;
  </code></pre>
  
  <p>Is there a way to get only the information that I'm looking for : <code>&lt;td&gt;109.123.00.00&lt;/td&gt;</code> or do I just need to strip the info from it manually?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>.asText() solved my issue, but gave quite a few warnings regarding the CSS. Should I be worried?</p>