apache / apache/jmeter

Problem with Node order using HtmlParsingUtils.getDOM which can impact HTML Link Parser

Open
#4,039 5 comments 0 reactions 0 assignees View on GitHub
os: All P5
Dominant language
Java
Stars
9.5k
Forks
2.3k
Avg merge
1d 22h
Merged PRs (30d)
5

Description

**David Hubbard** ([Bug 59943](https://bz.apache.org/bugzilla//show_bug.cgi?id=59943&redirect=false)):
Hi

I'm writing a PostProcessor in Java for JMeter - using HtmlParsingUtils.getDOM() to access the HTML response data.

In this I'm trying to pick out the Form fields from a response so that - when JMeter submits the form back - I can process the manage setting some of the posted param data.

My problem is the site I am trying to test returns some slightly wacky HTML, whereby several (showing one here) input field is included in a <table> element

<input name="1">
<input name="2" />
<table><tr><td><input name="3"></td>
<input name="4"></tr>
</table>

When fields get posted back by the browser they send them (form params) in-order (1+2+3+4) as expected.

However when using HtmlParsingUtils.getDOM() the node tree for the <table> seems to get included only when the </table> is parsed.

So the tree returned has 3 and 4 swapped
(input 1}
(input 2}
(input 4}
(table
(tr
(td
(input 3}
)
)
)

Is this a bug? I confess I'm not sure - it depends if the start tag <table> or end tag </table> are the trigger for adding, however, from my reading "input 4 is within the table node.

In this I can only assume that "input" fields are handled specially in the parser (since in html they don't need to include a closing tag or "/>" ?

What it means for me is that I order I post params from JMeter is affected and the app dosesn't like this. You might think that the app should handle params based on name even in wrong order, but the reality is that the input field names are not unique on the page - the app is using a framework with we can't change,

I have attached an example html file which show this.

Created attachment [simple.html](https://apache.github.io/jmeter-bugzilla-attachments/43/59943/34102/simple.html): Sample HTML response file
simple.html

````html


Sample





First name:



Last name:















First
Second













````

Severity: normal
OS: All

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.