¿Cómo capturar el cambio de "authenticity_token" en tiempo de ejecución usando el "Extractor de expresiones regulares" de Jmeter?
Frecuentes
Visto 1,406 equipos
0
He tratado de poner input\s+name=”authenticity_token”\s+type=”hidden”\s+value=”(.*?)”\s*\
in Jmeter's Regular Expression Extractor
but that is not helping and test fails. For Template
Mantuve $1$
siempre.
On viewing source of page it was written like this:
<input name="utf8" type="hidden" value="✓" /><input name="authenticity_token" type="hidden" value="OzzoQsvruAetQAiAMj5Mh4L730w0PUxzoALcgT3dI+o=" />
Based on above, how should I write contents for Regualr Expression Extractor
Please see pic below:
Its Ruby on Rails application
1 Respuestas
2
Según https://stackoverflow.com/a/1732454/2897748
No puede analizar [X]HTML con expresiones regulares. Porque HTML no puede ser analizado por expresiones regulares. Regex no es una herramienta que pueda usarse para analizar correctamente HTML.
I would strongly recommend using one of the following:
Example configuration of above to match your hidden input value:
CSS/JQuery
- Nombre de referencia:
token
- CSS/JQuery Expression:
input[name=authenticity_token]
- Atributo:
value
XPath
- Use Tidy - tick (if your response isn't XML/XHTML compliant)
- Nombre de referencia:
token
- XPath Query:
//input[@name='authenticity_token']/@value
If you still need to stick to Regular Expression Extractor, following configuration might help:
- Nombre de referencia:
token
- Expresión regular:
<input name="authenticity_token" type="hidden" value="(.+?)" />
- Plantilla:
$1$
But it will be very sensitive and fragile i.e. in case of attributes different order, multiline layout, etc. I would recommend consider using above extractors instead.
Espero que esto ayude.
contestado el 23 de mayo de 17 a las 13:05
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas regex jmeter authenticity-token or haz tu propia pregunta.
what's the difference? however I tried with
"
but it is still failing. - paulThe first is a right double quote..you can see how these characters differ in esta demo (note the capture groups on the right side). - Sam
It was failing for first one then I changed it to
"
, and then it failed again. - paulIntente removing the trailing
\s*\.
, if that doesn't work..then it is something with JMeter that I'm not familiar with. - Samlike this ` input+name="authenticity_token"+type="hidden"+value="(.*?)"*\ ` - paul