[Webtest] [webtest][JIRA] Created: (WT-69) setSelectField crashes app when trying to select an <option> tag that has no value attribute

Jake Newren (JIRA) webtest@lists.canoo.com
Fri, 22 Jul 2005 00:02:28 +0200 (CEST)


setSelectField crashes app when trying to select an <option> tag that has no value attribute
--------------------------------------------------------------------------------------------

         Key: WT-69
         URL: http://webtest-community.canoo.com/jira/browse/WT-69
     Project: WebTest
        Type: Bug
    Versions: 1.7-SNAPSHOT    
    Reporter: Jake Newren


When attempting to process a web page, WebTest crashes when it comes to an <option> tag that has no value attribute. Apparently htmlunit is unable to handle an <option> tag without an accompanying value attribute. When attempting to setSelectField it threw this exception:

 [testSpec] (steps.Step                          181 ) Start Step: setselectfield "" (22/52)
 [testSpec] (steps.Step                          374 ) Exception thrown from this class: com.gargoylesoftware.htmlunit.ElementNotFoundException
 [testSpec] (steps.Step                          376 ) Message was: elementName=[option] attributeName=[value] attributeValue=[Visa]
 [testSpec] (steps.Step                          387 ) Cannot handle unexpected exception in step SetSelectField at C:\Documents and Settings\Administ
rator\Desktop\webTestTrialRun.xml:66:  with (multiselect="false", value="Visa", description="", name="cardType", regex="false", stepType="setselectfie
ld")
 [testSpec] com.gargoylesoftware.htmlunit.ElementNotFoundException: elementName=[option] attributeName=[value] attributeValue=[Visa]
 [testSpec]     at com.gargoylesoftware.htmlunit.html.HtmlElement.getOneHtmlElementByAttribute(HtmlElement.java:451)
 [testSpec]     at com.gargoylesoftware.htmlunit.html.HtmlSelect.getOptionByValue(HtmlSelect.java:465)
 [testSpec]     at com.canoo.webtest.steps.form.SetSelectField.findMatchingOption(SetSelectField.java:109)
 [testSpec]     at com.canoo.webtest.steps.form.SetSelectField.updateField(SetSelectField.java:72)
 [testSpec]     at com.canoo.webtest.steps.form.AbstractSetNamedFieldStep.findThenSetField(AbstractSetNamedFieldStep.java:34)
 [testSpec]     at com.canoo.webtest.steps.form.AbstractSetFieldStep.doExecute(AbstractSetFieldStep.java:82)
 [testSpec]     at com.canoo.webtest.steps.Step.execute(Step.java:96)
 [testSpec]     at com.canoo.webtest.engine.Engine.executeSteps(Engine.java:30)
 [testSpec]     at com.canoo.webtest.ant.TestSpecificationTask.execute(TestSpecificationTask.java:67)
 [testSpec]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
 [testSpec]     at org.apache.tools.ant.Task.perform(Task.java:364)
 [testSpec]     at org.apache.tools.ant.Target.execute(Target.java:341)
 [testSpec]     at org.apache.tools.ant.Target.performTasks(Target.java:369)
 [testSpec]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
 [testSpec]     at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
 [testSpec]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
 [testSpec]     at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
 [testSpec]     at org.apache.tools.ant.Main.runBuild(Main.java:668)
 [testSpec]     at org.apache.tools.ant.Main.startAnt(Main.java:187)
 [testSpec]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
 [testSpec]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
 [testSpec] (ant.TestSpecificationTask           150 ) Writing report using Report class: com.canoo.webtest.reporting.XmlReporter
 [testSpec] (ant.TestSpecificationTask           166 ) Test summary successfully created.

BUILD FAILED
C:\Documents and Settings\Administrator\Desktop\webTestTrialRun.xml:22: Test failed.
Exception raised: com.canoo.webtest.engine.StepExecutionException: Unexpected exception caught: com.gargoylesoftware.htmlunit.ElementNotFoundException
: elementName=[option] attributeName=[value] attributeValue=[Visa], Step: SetSelectField at C:\Documents and Settings\Administrator\Desktop\webTestTri
alRun.xml:66:  with (multiselect="false", value="Visa", description="", name="cardType", regex="false", stepType="setselectfield")com.canoo.webtest.en
gine.StepExecutionException: Unexpected exception caught: com.gargoylesoftware.htmlunit.ElementNotFoundException: elementName=[option] attributeName=[
value] attributeValue=[Visa], Step: SetSelectField at C:\Documents and Settings\Administrator\Desktop\webTestTrialRun.xml:66:  with (multiselect="fals
e", value="Visa", description="", name="cardType", regex="false", stepType="setselectfield")
        at com.canoo.webtest.steps.Step.handleUnexpectedException(Step.java:388)
        at com.canoo.webtest.steps.Step.execute(Step.java:99)
        at com.canoo.webtest.engine.Engine.executeSteps(Engine.java:30)
        at com.canoo.webtest.ant.TestSpecificationTask.execute(TestSpecificationTask.java:67)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:341)
        at org.apache.tools.ant.Target.performTasks(Target.java:369)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
        at org.apache.tools.ant.Main.runBuild(Main.java:668)
        at org.apache.tools.ant.Main.startAnt(Main.java:187)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)

The relevant HTML that was causing the issue:

<select name="cardType" class="selectBox">
          <option></option>

          <option></option>
          <option>Visa</option>
          <option value='MasterCard'>Master Card</option>
          <option value='AmericanExpress'>American Express</option>
          <option value='DinersClub'>Diners Club</option>
          <option>Discover</option>
          <option>EnRoute</option>
          <option>JCB</option>
        </select>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://webtest-community.canoo.com/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira