Menu

#156 Set input field tags blow up when null is passed.

3.3-M2
closed-fixed
5
2014-08-26
2006-08-30
kaki
No

The issue occures when you write data-driven test step
closed in <jm:cvs> tag and you want to implement
filling form, but of course you don't want to fill all
the input forms, so you leave empty fields in CSV file.
When you tries to run such test step inside test case
you get newValue exception. This exception is cause by
Assert.notNull() method from Assert.java called in line
90 in HtmlInput.java, setValueAttribute method which is
a part of HtmlUnit. This method is called by HtmlUnit
plug-in in AbstractHtmlUnitSetInputFieldTag class,
setInputFieldFoundByXPath method. I resolved this by
adding if(value != null) on line 40 in
AbstractHtmlUnitSetInputFieldTag.java (before
inputField.setValueAttribute(value);). Input fields
with no value in cvs are just not filled now. i
recommend this solution for next HtmlUnit plug-in.

Log fragment for the mentioned Exception:

BEGIN: Fill First Name field.
java.lang.NullPointerException: newValue
at
com.gargoylesoftware.htmlunit.Assert.notNull(Assert.java:60)
at
com.gargoylesoftware.htmlunit.html.HtmlInput.setValueAttribute(HtmlInput.java:90)
at
net.sf.jameleon.plugin.htmlunit.tags.AbstractHtmlUnitSetInputFieldTag.setInputFieldFoundByXPath(AbstractHtmlUnitSetInputFieldTag.java:40)
at
net.sf.jameleon.plugin.htmlunit.tags.AbstractHtmlUnitSetInputFieldTag.setFieldValueFoundByXPath(AbstractHtmlUnitSetInputFieldTag.java:33)
at
net.sf.jameleon.plugin.htmlunit.tags.AbstractHtmlUnitSetFormFieldTag.testBlock(AbstractHtmlUnitSetFormFieldTag.java:57)
at
net.sf.jameleon.function.FunctionTag.testBlock(FunctionTag.java:258)
at
net.sf.jameleon.function.FunctionTag.doTag(FunctionTag.java:290)
at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:247)
at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at
org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
at
net.sf.jameleon.data.AbstractDataDrivableTag.executeDrivableRow(AbstractDataDrivableTag.java:247)
at
net.sf.jameleon.data.DataExecuter.executeData(DataExecuter.java:80)
at
net.sf.jameleon.data.AbstractDataDrivableTag.doTag(AbstractDataDrivableTag.java:335)
at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:247)
at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at
org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
at
net.sf.jameleon.SessionTag.doTag(SessionTag.java:180)
at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:247)
at
org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
at
org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
at
net.sf.jameleon.TestCaseTag.invokeChildren(TestCaseTag.java:618)
at
net.sf.jameleon.TestCaseTag$1.run(TestCaseTag.java:762)
at
net.sf.jameleon.TestCaseTag.executeBody(TestCaseTag.java:821)
at
net.sf.jameleon.TestCaseTag.executeNoCSV(TestCaseTag.java:760)
at
net.sf.jameleon.TestCaseTag.doTag(TestCaseTag.java:722)
at
org.apache.commons.jelly.impl.TagScript.run(TagScript.java:247)
at
org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:704)
at
org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:668)
at
org.apache.commons.jelly.JellyContext.runScript(JellyContext.java:577)
at
net.sf.jameleon.ExecuteTestCase.runScript(ExecuteTestCase.java:219)
at
net.sf.jameleon.ui.TestCasePane$3.run(TestCasePane.java:298)

Discussion

  • Christian Hargraves

    Logged In: YES
    user_id=60860

    Which tag are you using that reproduces this problem?

    Also, if you could provide a reproducable test case, this
    would help a lot.

    The fact that a non-defined variable in a data tag is set
    to null is an intended feature. I could add a setting
    that changed the behavior of setting the variable to null
    to setting it to am empty String.

    If you want this feature, please create a feature request.

    In the meantime, if I am to fix this bug, I need a
    producable test case and the tag which is causing this
    error (assuming it's a plug-in provided tag)

     
  • Christian Hargraves

    • milestone: 616749 --> 3.3-M2
    • summary: newValue Exception for empty fields in CSV file --> Unknown HtmlUnit plug-in tag blows up when null is passed.
    • labels: 886104 --> 542588
     
  • kaki

    kaki - 2006-08-30

    Source with bug cause example

     
  • Christian Hargraves

    • status: open --> closed-fixed
     
  • Christian Hargraves

    Logged In: YES
    user_id=60860

    This fix has been commited to CSV and will included in the
    next release

     
  • Christian Hargraves

    • summary: Unknown HtmlUnit plug-in tag blows up when null is passed. --> Set input field tags blow up when null is passed.
     
  • Christian Hargraves

    • labels: 542588 --> HtmlUnit plug-in
     

Log in to post a comment.

Auth0 Logo