Gatling parsing html

I’ve appended this statement to a step


The problems here is : I’m receiving a little malformed html in response and hence it can not build response.

notice the missing quotes after hspace.

Gatling throws an error : SaxParserError : opening quotes are missing after attribute ‘hspace’…
and ‘Response could not be built’ at the end.

I know this malformed html is (my) bad, but Is there any workaround here ? I’m trying to load test a large enterprise system and do not have an access to the code. Also, client will not be willing to make changes through out the code just for load testing.


If you do not expect xHTML, then you cannot use XPath. (speaking striclty, HTML is weel formed in your example, but if it is supposed to be xHTML then, xHTML is malformed :))

You could use Regular Expressions even though this is quite painful…

You can also try css selectors, this might do the trick :wink:


Thanks for the quick reply. I’m trying to use regex as I do not have any css options.

But I run into another problem. the html element I’m accessing has number of while spaces inside the tags. Can I use any other reg-ex apart from the capture group ?

.check(regex(“Doc Nbr:/\s{2,}/g([0-9]*)”).saveAs(“doc_id”))

notice the reg-ex between and . I need to put it between every elements :frowning:
I tried this and it results in compilation failure !

I think you missed the escaping character :slight_smile:

Try with triple double-quotes around your regex : “”" regex “”" instead of " regex "

I tried that but It does not evaluate reg-ex, and treats it as simple text.

However, I found a workaround as a hidden parameter contains the same value and I will not have white-spaces issue with that.

I’m working on a small script and it is taking days :frowning: But at the same time, I’d accept that I don’t even dare to touch Jmeter’s XML.

I seriously thank Gatling Team to bring programming language to load-test scripting :slight_smile:

Did you achieve what you wanted to do ? ^^

I didn’t understand what was your problem juste before, and now it seems obvious that your regex cannot work.

You didn’t use java regular expression syntax. I think your regex should have been :

“Doc Nbr:[ ]{2,}([0-9])" instead of "Doc Nbr:/\s{2,}/g([0-9])”

I’d try like this personnally ^^

Hi Romain,

I tried that, but looks like it could not match anything in response.
But that’s ok for now, as I found a workaround.

OK, great! :wink: