<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Object Mentor Blog: Dependency Management: HtmlUnit</title>
    <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Dependency Management: HtmlUnit</title>
      <description>&lt;p&gt;If you are planning on building an &lt;span class="caps"&gt;API&lt;/span&gt;, please, please, think about dependency management.  Don&amp;#8217;t make me know more about your world view than necessary.  Consider what happened to me as I explored HtmlUnit&amp;#8230;&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m using HtmlUnit to parse and interpret &lt;span class="caps"&gt;HTML&lt;/span&gt; web pages.  I&amp;#8217;ve been very impressed with this library so far.  And I appreciate the hard work and dedication of people who give their software away for free.  So, although this blog is a complaint, it should not be misconstrued into anything more than constructive criticism.  Besides, what I am complaining about here is so universal that it really wouldn&amp;#8217;t matter whose software I chose to scrutinize.  The HtmlUnit authors just got lucky in this case.&lt;/p&gt;


What I want to do with HtmlUnit is quite simple.  Given a string containing &lt;span class="caps"&gt;HTML&lt;/span&gt;, I&amp;#8217;d like to query that &lt;span class="caps"&gt;HTML&lt;/span&gt; for certain tags and attributes.  For example, I&amp;#8217;d like to do this:
&lt;pre&gt;&lt;code&gt;
    HtmlPage page = HTMLParser.parse(htmlString);
    HtmlElement html = page.getDocumentElement();
    HtmlElement listForm = html.getHtmlElementById("list_form");
    assertEquals("/Library/books/manage.do", listForm.getAttributeValue("Action"));&lt;/code&gt;&lt;/pre&gt;
Sweet, simple, uncomplicated.  Just create the &lt;span class="caps"&gt;DOM&lt;/span&gt; from an &lt;span class="caps"&gt;HTML&lt;/span&gt; String, and then query that &lt;span class="caps"&gt;DOM&lt;/span&gt;. 

Unfortunately, HtmlUnit does not appear to be that simple.  What you have to do instead looks like this:
&lt;pre&gt;&lt;code&gt;    StringWebResponse stringWebResponse = new StringWebResponse(htmlString);
    WebClient webClient = new WebClient();
    webClient.setJavaScriptEnabled(false);
    HtmlPage page = HTMLParser.parse(stringWebResponse, new TopLevelWindow("", webClient));
    HtmlElement html = page.getDocumentElement();
    HtmlElement listForm = html.getHtmlElementById("list_form");
    assertEquals("/Library/books/manage.do", listForm.getAttributeValue("Action"));&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;The extra &lt;em&gt;stuff&lt;/em&gt; in here is apparently due to the fact that the authors wanted to be able to simulate browsers, frames, and javascript.  I think their goal was laudable.  However, I wish they had done this without forcing those frames, browsers, and script engines down my throat.&lt;/p&gt;


	&lt;p&gt;Given my simple needs, why do I care about WebClient and Window.  Why do I have to turn off the javascript engine?  It may seem a small thing, but it bothers me nonetheless.  It&amp;#8217;s the principle of the matter that gets under my skin.  The pragmatic programmers called it &lt;em&gt;The Principle of Least Surprise&lt;/em&gt;.  I call it, simply, &lt;em&gt;dependency management&lt;/em&gt;.  &lt;em&gt;Don&amp;#8217;t make people depend on more than they need.&lt;/em&gt;&lt;/p&gt;


	&lt;p&gt;The cost, to me, was an hour of rooting around in the documentation, example code, and my own trial-and-error experiments.  (The benefit to me was another blog topic ;-)  That cost may not seem great; but it must be paid again and again by everyone who wants to use the package in a way that doesn&amp;#8217;t quite fit the authors&amp;#8217; world view.&lt;/p&gt;


	&lt;p&gt;There may, in fact, be a simpler way to do what I want to do with HtmlUnit.  If there is, I haven&amp;#8217;t been able to find it, and I&amp;#8217;d be grateful if anyone out there, including the authors, could guide me in the right direction.&lt;/p&gt;</description>
      <pubDate>Sun, 11 Feb 2007 12:55:14 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:30d33c2e-6b0e-4c4c-8f17-e8664251611b</guid>
      <author>Uncle Bob</author>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit</link>
      <category>Uncle Bob's Blatherings</category>
      <trackback:ping>http://blog.objectmentor.com/articles/trackback/159</trackback:ping>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by coach handbags uk</title>
      <description>&lt;p&gt;Its like you read my mind! You appear to know so much about this, like you wrote the book in it or something.&lt;/p&gt;</description>
      <pubDate>Mon, 06 Feb 2012 18:54:17 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:3d658eb2-41a4-45a8-a253-dde92684f505</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-201971</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by writing service</title>
      <description>&lt;p&gt;Essay writing company , college term papers, buy research paper .&lt;/p&gt;</description>
      <pubDate>Mon, 30 Jan 2012 05:22:02 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:7ef832da-bb2e-46bc-a09c-8c2e7ddec91e</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-200207</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by psk</title>
      <description>&lt;p&gt;There is appreciably a lot to know about this. I&#8217;m glad reading this content, I very much like and agree with your thoughts.&lt;/p&gt;</description>
      <pubDate>Thu, 26 Jan 2012 01:10:03 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:ccca82c8-5ee8-4332-9be3-9b43ff051e1e</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-199209</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by psb</title>
      <description>&lt;p&gt;Good stufff&amp;#8230;
keep it up..&lt;/p&gt;</description>
      <pubDate>Mon, 23 Jan 2012 23:03:47 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:e0c36f86-c61d-4663-833e-fb6adb9a9147</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-198972</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by custom essay paper</title>
      <description>&lt;p&gt;Academic research papers, 
&lt;a href="http://www.genuinewriting.com" rel="nofollow"&gt;buy a research paper&lt;/a&gt;, buy essay paper online.&lt;/p&gt;</description>
      <pubDate>Fri, 20 Jan 2012 02:30:31 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:06d59653-ac1e-45a1-ae06-cced90cb1d3b</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-198668</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by iolo coupon</title>
      <description>&lt;p&gt;I like this concept. I visited your blog for the first time and just been your fan. Keep posting as I am gonna come to read it everyday. Thanks for sharing.&lt;/p&gt;</description>
      <pubDate>Thu, 12 Jan 2012 03:07:10 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:b4dae233-45f8-40c9-9cd0-ec84c6bd0d35</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-197334</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by ithemes coupon code</title>
      <description>&lt;p&gt;thanks for ur sharing, I like your blog, content is very rich, allow me to leave a message well, wish you are lucky!!!!!&lt;/p&gt;</description>
      <pubDate>Wed, 11 Jan 2012 15:40:02 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:3454e18d-4e11-403e-b0ae-040a29c958db</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-197008</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by  where and how</title>
      <description>&lt;p&gt;. Perfect ideas for your story and great food for thought&lt;/p&gt;</description>
      <pubDate>Tue, 27 Dec 2011 19:36:53 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:a7f7424c-8fea-4851-8227-8cff817993ae</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-192652</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by LiMelia</title>
      <description>&lt;p&gt;thanks for ur sharing, I like your blog, content is very rich, allow me to leave a message well, wish you are lucky!!!!!
&lt;a href="http://www.junyuetrade.com/" rel="nofollow"&gt;http://www.junyuetrade.com/&lt;/a&gt;&lt;/p&gt;
  
  </description>
      <pubDate>Sun, 27 Nov 2011 04:33:11 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:4c0561ba-cde8-455b-ac9f-fa8df750b15a</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-178877</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by christian louboutin</title>
      <description>&lt;p&gt;Good artical,I learn something!&lt;/p&gt;</description>
      <pubDate>Sun, 30 Oct 2011 06:31:15 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:91bd7db4-e1b2-418e-aad6-2cfab89cd2cc</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-165737</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by christian louboutin</title>
      <description>&lt;p&gt;Good artical,I learn something!&lt;/p&gt;</description>
      <pubDate>Sun, 30 Oct 2011 05:20:40 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:46bc9689-5225-4d4c-b797-e2626489392a</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-165704</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by hair extensions cost</title>
      <description>&lt;p&gt;Also prefer to admire the time and work you place into your weblog as well as in level information and details you offer! i am going to bookmark your weblog and also have my youthful children confirm up right here often.&lt;/p&gt;</description>
      <pubDate>Tue, 25 Oct 2011 04:16:19 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:fb412506-0d7c-4e82-97d6-4b76c4840c4d</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-163153</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by Ashley Bowling</title>
      <description>&lt;p&gt;One computer might easily replace 100 white-collar &amp;#8216;pencil pushers&amp;#8217;,&lt;/p&gt;</description>
      <pubDate>Sun, 16 Oct 2011 05:32:07 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:049309ba-b25a-424d-9b6c-6f22deac3a69</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-157356</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by carpet cleaning</title>
      <description>&lt;p&gt;This is really stunning work.Thanks for this kind of stuff.I wanna say I am totally impressed.Hope to see some more update work here.I have to say it is quite impressing.&lt;/p&gt;</description>
      <pubDate>Thu, 13 Oct 2011 13:08:04 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:583a4e0c-37b0-413f-bd99-1ba98bc86029</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-156051</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by beats by dr   dre</title>
      <description>&lt;p&gt;important.Thanks for the nice written article being shared here.Love your&lt;a href="http://www.drdrebeatsheadphones-australia.com" rel="nofollow"&gt;beats by dr dre&lt;/a&gt;
&lt;a href="http://www.drdrebeatsheadphones-australia.com" rel="nofollow"&gt;beats by dre sale&lt;/a&gt; concept and making it very clearance indeed&lt;/p&gt;</description>
      <pubDate>Mon, 29 Aug 2011 21:46:24 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:818a0595-a29f-4098-ad62-3ee31863b11b</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-134056</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by Jewellery Xy</title>
      <description>&lt;p&gt;Nice work uncle Bob. Saved me some time with your information on html unit.
Only genuine and authentic designer&lt;a href="http://www.jewelleryxy.com/brand-name-handbags.html" rel="nofollow"&gt; brand name handbags &lt;/a&gt; at discounted prices. Our brands include gucci, guess, calvin klein, diesel, prada&lt;/p&gt;</description>
      <pubDate>Sun, 21 Aug 2011 14:02:57 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:1b9aa9c7-0e35-4a03-b8d7-512a0947d57e</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-130333</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by austin remodeler</title>
      <description>&lt;p&gt;Dependency management is really important.Thanks for the nice written article being shared here.Love your concept and making it very clearance indeed.&lt;/p&gt;</description>
      <pubDate>Fri, 19 Aug 2011 10:07:39 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:1722c194-f6eb-4610-881f-021b62cd3a5c</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-129903</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by monicajoy56</title>
      <description>&lt;p&gt;Nice Article. Wish to get such article again again. Thanks a lot for sharing this.&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://highendhomebuilders.com" rel="nofollow"&gt;Scottsdale Custom Home Builders&lt;/a&gt;
&lt;a href="http://highendhomebuilders.com" rel="nofollow"&gt;High End Home Builders&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sun, 10 Jul 2011 13:20:37 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:430e496f-43a7-42f7-996a-e494ddc84bdd</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-116739</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by Coach Tote</title>
      <description>&lt;p&gt;I am happy to have found this blog, and more happy to have long tail explained so well. Thanks.&lt;/p&gt;</description>
      <pubDate>Fri, 08 Jul 2011 03:49:56 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:deb8aa6a-ec63-4126-903c-29986e9f0af1</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-116222</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by Pandora Rings</title>
      <description>&lt;p&gt;Every woman does have a sole desire to have the perfect kind of fashion lady designer jewellery. In essence, there are more than enough fashion jewellery designs available online. One of them is fabulously known as the &lt;a href="http://www.magicjewelrybox.net/Pandora-Rings_5_1.htm" rel="nofollow"&gt;Pandora Rings&lt;/a&gt;. Generally it is a kind of women antique. It is very lovely and versatile kind of jewellery for the gracious looking ladies in the world today. Most the Pandora bracelets can be available in lots of sizzling styles and designs online. For example, there is a demand of wearing the &lt;a href="http://www.magicjewelrybox.net/Pandora-Bangles_9_1.htm" rel="nofollow"&gt;Pandora Bangles&lt;/a&gt; around your neck; you should not hesitate to use it on time at all. The greatest advantage of using the Pandora bracelets is that they would abruptly boost up your natural beauty and grace for long time. Greatly online replica jewellery shop offers you greatest kinds of fashion designer replica jewels online.&lt;/p&gt;</description>
      <pubDate>Fri, 08 Jul 2011 03:35:50 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:6a94f095-fa7b-42da-8834-cf45235b50f3</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-116217</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by complete websites for sale</title>
      <description>&lt;p&gt;This is excellent  post. Its having good description regarding this topic.It is informative and helpful.I have known many information from this. Thanks for shearing.&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.tomhelmandpartners.com/site-for-sell/" rel="nofollow"&gt;complete websites for sale&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 07 Jul 2011 06:05:30 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:5d818b73-1bc2-4193-8164-b95320199644</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-115758</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by septic system</title>
      <description>&lt;p&gt;Thanks for the nice written article.I found this thing so much helpful.&lt;/p&gt;</description>
      <pubDate>Sat, 02 Jul 2011 12:12:23 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:fc14a425-6b29-4ae8-aeeb-7c0b0124be91</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-113970</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by deadbeat millionaire</title>
      <description>&lt;p&gt;very cool blog post ! i&amp;#8217;ve been reading this blog for some time and it have cool content!&lt;/p&gt;</description>
      <pubDate>Fri, 17 Jun 2011 15:40:34 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:6df995fc-96ab-4750-a63e-c0e507d577a9</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-111919</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by Unique Article Wizard </title>
      <description>&lt;p&gt;very nice article ! quite helpful for a newbie like me !&lt;/p&gt;</description>
      <pubDate>Fri, 17 Jun 2011 14:44:23 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:7f8a0e1e-76dd-4d76-a2fd-25d62aac4857</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-111855</link>
    </item>
    <item>
      <title>"Dependency Management: HtmlUnit" by router table</title>
      <description>&lt;p&gt;The web client and the window and the java script causes problem for some. Anyway as everything has some sort of disadvantages this software may also have them but the point we have to&lt;/p&gt;</description>
      <pubDate>Thu, 16 Jun 2011 05:33:09 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:36df4e17-d2f7-41be-af63-28e45c7b501e</guid>
      <link>http://blog.objectmentor.com/articles/2007/02/11/dependency-management-httpunit#comment-111417</link>
    </item>
  </channel>
</rss>

