Parsing HTML via JMeter regexp

前端 未结 3 406
予麋鹿
予麋鹿 2021-01-25 04:46

I have some trouble with a regex in JMeter. I have this form in HTML

相关标签:
3条回答
  • 2021-01-25 04:56

    Jmeter uses PERL regular expressions to extract and store values into variables.

    Here is a great resource for learning how to write them: http://www.regular-expressions.info/

    Here's the link for the Jmeter user manual: http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor

    In Jmeter, make sure you put parentheses () around the items you want to store to the variable. Given you're new to JMeter, I would recommend having TWO regular expressions - one for each item. This will make it easier for you to track and debug. You'll end up with expressions like: componentId=(.+?);

    0 讨论(0)
  • 2021-01-25 05:02

    Please don't use regular expressions for getting attribute values. There's so many corner cases in terms of character escaping and such that it's likely to break sometime. Look into XML processing APIs, like SAX, StAX, DOM or XSLT. Do mind that this requires the HTML to be XML compliant (if it's XHTML that's covered).

    Once you get the value of your action attribute via a suitable API, you can then unleash regular expressions on it.

    Alternatively, find out if you can somehow harness what already exists for handling HTTP posts/gets via the Servlet API or something similar. They place URL parameters in a map for retrieval.

    0 讨论(0)
  • 2021-01-25 05:15

    Use an XPath Extractor instead.

    If you must use a regex, just search for regex tag parsing.

    0 讨论(0)
提交回复
热议问题