Gatling parsing html

1,121 views
Skip to first unread message

Tejas Shah

unread,
Feb 27, 2013, 5:52:15 AM2/27/13
to gat...@googlegroups.com
I've appended this statement to a step

.check(xpath("//*[@id='headerarea']/div/table/tbody/tr[1]/td[1]/@value").saveAs("doc_id"))

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

<img id="myimg" src="somethingvalid" hspace=5 />

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.


Romain Sertelon

unread,
Feb 27, 2013, 6:12:12 AM2/27/13
to gat...@googlegroups.com

Hi,

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 ;)

Cheers,

--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
--
Romain SERTELON
Blog ~ @BluePyth ~ +BluePyth ~ Github ~ LinkedIn ~ DoYouBuzz ~ Lanyrd

Tejas Shah

unread,
Feb 27, 2013, 7:45:14 AM2/27/13
to gat...@googlegroups.com
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:</th>/\s{2,}/g<td>([0-9]*)</td>").saveAs("doc_id"))

notice the reg-ex between </th> and <td>. I need to put it between every elements :(
I tried this and it results in compilation failure !

--
You received this message because you are subscribed to a topic in the Google Groups "Gatling User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gatling/SdK4WR5aojk/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to gatling+u...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
---------------------
Tejas M Shah
Group Lead - Tech

ArguSoft India Ltd
Tel: +91 79 23287029  Xtn: 109
cell: +91 9974550108

Romain Sertelon

unread,
Feb 27, 2013, 8:26:26 AM2/27/13
to gat...@googlegroups.com

I think you missed the escaping character :)

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

Tejas Shah

unread,
Feb 27, 2013, 8:41:09 AM2/27/13
to gat...@googlegroups.com
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 :( But at the same time, I'd accept that I don't even dare to touch Jmeter's XML.

Tejas Shah

unread,
Feb 27, 2013, 8:42:16 AM2/27/13
to gat...@googlegroups.com
I seriously thank Gatling Team to bring programming language to load-test scripting :)

Romain Sertelon

unread,
Feb 27, 2013, 9:12:49 AM2/27/13
to gat...@googlegroups.com

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:</th>[ ]{2,}<td>([0-9]*)</td>" instead of "Doc Nbr:</th>/\s{2,}/g<td>([0-9]*)</td>"

I'd try like this personnally ^^

Tejas Shah

unread,
Feb 28, 2013, 1:00:54 AM2/28/13
to gat...@googlegroups.com
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.

Romain Sertelon

unread,
Feb 28, 2013, 2:31:16 AM2/28/13
to gat...@googlegroups.com

OK, great! ;)

Reply all
Reply to author
Forward
0 new messages