如何检查Jmeter中的响应,以便每个响应应包含规范链接?

时间:2017-05-16 09:10:16

标签: jmeter seo assertions

例如,我有网址列表。 每个URL都应在HTML正文的头部包含以下参数:

<link rel="canonical" href="http://example.com/xxx/yyy/zzz/">

“href”中显示的参数,与请求的确切URL重复。

我应该使用什么类型的断言以及如何配置它以自动检查7k +的URL?

主要思想是检查响应代码(它应该是200),并且“href”中的参数与URL具有相同的值。

1 个答案:

答案 0 :(得分:1)

  1. Extract URL

    • Add Regular Expression Extractor as a child of the request (or if you have a lot of requests put it on the same level as the requests) and configure it as follows:

      • Reference Name: anything meaningful, i.e. url
      • Regular Expression: (.*)
      • Template: $1$

        JMeter Regex Extract URL

  2. Perform response validation.

    • Add Response Assertion (the same scope as the Regular Expresion Extractor) and configure it as follows

      • Apply to: Main sample only
      • Pattern Matching Rules: Substring
      • Patterns to Test: <link rel="canonical" href="${url}">

        JMeter Assertion Validate URL