0

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
Enwar
  • 3
  • 1
  • 1
    Please revisit your question and use the edit button to highlight the code. As of now, it remains unclear what you want. – Jan Mar 13 '17 at 20:33

2 Answers2

1
name="j_id_s_1_SUBMIT"\svalue="(.+?)"\s/>

if you don't tell it to stop after first match (which is ? after .+), it's gonna take as broad match, as possible - and that's what happened.

PS But that's following your expression, while by it you'll get 1, not that token you'd needed.

So, to get your stuff, you'd better do

id="j_id__v_0:javax\.faces\.ViewState:1"\svalue="(.+?)"\sautocomplete

PPS Your html seem to be well-formed, why not use XPath extractor then? You'd not be dependent on the attributes order and/or overall structure of HTML in your response then.

PPPS And here's even better trick right from official JMeter doc:

Note: although the above expression works, it's more efficient to use the following expression: name="file" value="([^"]+)"> where [^"] - means match anything except " In this case, the matching engine can stop looking as soon as it sees the first ", whereas in the previous case the engine has to check that it has found "> rather than say " >.

RTFM is still trendy, isn't it? :-)

Yuri G
  • 1,206
  • 1
  • 9
  • 13
  • Thanks. Rally appreciated ! – Enwar Mar 14 '17 at 14:13
  • Thanks. Rally appreciated ! now it gives me right value, I try to update address in my application, and submit, I put the viewstate value, but it still throws 500 error, should I use other value as well? when I use blazemeter record, it gives me like this value ViewSate=4bAuxA6j/nZjdtHd6s1UxM75jfae6h2OwGJvRZZXY8I7wK1Q thanks, for the answer. – Enwar Mar 14 '17 at 14:26
1

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
Community
  • 1
  • 1
Dmitri T
  • 159,985
  • 5
  • 83
  • 133