Search code examples
regexjmeterbeanshell

Jmeter Regular Expression


I am struggling find solution to Jmtere dynamic input value which return one matched value but with the sub strings.

</script></span><input type="hidden" name="j_id_s_1_SUBMIT" value="1" /><input type="hidden" name="javax.faces.ViewState" id="j_id__v_0:javax.faces.ViewState:1" value="07JgPgLP3e1jdtHd6s1UxDoKEaCU362MYbfU48r9paGrBDfo" autocomplete="off" /></form>

i try to get "07JgPgLP3e1jdtHd6s1UxDoKEaCU362MYbfU48r9paGrBDfo" this value. i reuslar expression:

j_id_s_1_SUBMIT" value="(.+)"

referencename: view

It returns:

Match count: 1
Match[1][0]=j_id_s_1_SUBMIT" value="1" /><input type="hidden" name="javax.faces.ViewState" id="j_id__v_0:javax.faces.ViewState:1" value="07JgPgLP3e1jdtHd6s1UxDoKEaCU362MYbfU48r9paGrBDfo" autocomplete="off"
Match[1][1]=1" /><input type="hidden" name="javax.faces.ViewState" id="j_id__v_0:javax.faces.ViewState:1" value="07JgPgLP3e1jdtHd6s1UxDoKEaCU362MYbfU48r9paGrBDfo" autocomplete="off

i tried ${__substring(${view}, 101, 149)} , my script still fail. Any other solutions? Thanks


Solution

  • Simply Don't use regular expressions to parse HTML, a minor markup change, adding or replacing an attribute, rendering a part of tag on the next line, whatever and your test is ruined.

    You have:

    • XPath Extractor, relevant XPath query will be as simple as //input[@name='javax.faces.ViewState']/@value
    • CSS/JQuery Extractor, selection will be input[name=javax.faces.ViewState], use value as the attribute