Revision: 940 http://jwebunit.svn.sourceforge.net/jwebunit/?rev=940&view=rev Author: henryju Date: 2012-07-25 12:16:24 +0000 (Wed, 25 Jul 2012) Log Message: ----------- Fix getting value of option element when no value attribute is specified.
Modified Paths: -------------- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java =================================================================== --- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java 2012-07-25 11:08:23 UTC (rev 939) +++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java 2012-07-25 12:16:24 UTC (rev 940) @@ -29,6 +29,7 @@ import com.gargoylesoftware.htmlunit.html.DomNode; import com.gargoylesoftware.htmlunit.html.HtmlElement; import com.gargoylesoftware.htmlunit.html.HtmlInput; +import com.gargoylesoftware.htmlunit.html.HtmlOption; import com.gargoylesoftware.htmlunit.html.HtmlTextArea; /** @@ -55,10 +56,15 @@ * @see net.sourceforge.jwebunit.api.IElement#attribute(java.lang.String) */ public String getAttribute(String name) { - if (!element.hasAttribute(name)) - return null; - - return element.getAttribute(name); + if ("value".equals(name) && element instanceof HtmlOption) { + // for options, we want text if no value was specified + return ((HtmlOption) element).getValueAttribute(); + } else { + if (!element.hasAttribute(name)) + return null; + + return element.getAttribute(name); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ JWebUnit-development mailing list JWebUnit-development@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jwebunit-development