尝试检查响应代码时 Taurus 出错
Taurus error when try to check response code
我正在尝试断言 HTTP GET 的响应
execution:
- executor: selenium
scenario: dashboard
iterations: 1
reporting:
- module: final-stats
dump-xml: results/test.xml
dump-csv: results/test2.csv
- module: junit-xml
filename: results/testfinal.xml
data-source: pass-fail
modules:
console:
disable: true
scenarios:
dashboard:
browser: Chrome
timeout: 60s
default-address: https://${URL}
requests:
- label: ignore
url: https://${URL}
actions:
- waitByXPath(/html/body/div/div[2]/div/div/div/div[4]/div[2]/form/input[4]): Visible
- keysByXPath(/html/body/div/div[2]/div/div/div/div[4]/div[2]/form/input[4]): ${USERNAME}
- keysByXPath(/html/body/div/div[2]/div/div/div/div[4]/div[2]/form/input[5]): ${PASSWORD}
- clickByXPath(/html/body/div/div[2]/div/div/div/div[4]/div[2]/form/div[4]/button)
- url: /Sites/testsite/api/level1/status/auth-service-health-check
method: GET
assert:
- contains:
- 200
subject: status-code
我得到的错误是 "TypeError: first argument must be string or compiled pattern"
请任何人帮忙解决这个问题
我需要检查的是 url 的响应状态是否为 200:/Sites/testsite/api/level1/status/auth-service-health-check
问题就在这里
- contains:
- 200
subject: status-code
如果我这样添加,这个错误就消失了,但它会检查响应正文而不是状态代码
- contains:
- '200'
subject: status-code
您是否尝试过将 subject
更改为 http-code
?:
subject: http-code
检查 http-code 而不是 status-code 的建议是正确的。要对此进行扩展,请查看此处的解释:
https://gettaurus.org/docs/JMeter/#HTTP-Requests
向下滚动一点,可以看到有关断言在 Taurus 中的确切工作原理的讨论,以及一些示例。特别要注意的是这部分:
Possible subjects are:
body
headers
http-code
我正在尝试断言 HTTP GET 的响应
execution:
- executor: selenium
scenario: dashboard
iterations: 1
reporting:
- module: final-stats
dump-xml: results/test.xml
dump-csv: results/test2.csv
- module: junit-xml
filename: results/testfinal.xml
data-source: pass-fail
modules:
console:
disable: true
scenarios:
dashboard:
browser: Chrome
timeout: 60s
default-address: https://${URL}
requests:
- label: ignore
url: https://${URL}
actions:
- waitByXPath(/html/body/div/div[2]/div/div/div/div[4]/div[2]/form/input[4]): Visible
- keysByXPath(/html/body/div/div[2]/div/div/div/div[4]/div[2]/form/input[4]): ${USERNAME}
- keysByXPath(/html/body/div/div[2]/div/div/div/div[4]/div[2]/form/input[5]): ${PASSWORD}
- clickByXPath(/html/body/div/div[2]/div/div/div/div[4]/div[2]/form/div[4]/button)
- url: /Sites/testsite/api/level1/status/auth-service-health-check
method: GET
assert:
- contains:
- 200
subject: status-code
我得到的错误是 "TypeError: first argument must be string or compiled pattern"
请任何人帮忙解决这个问题 我需要检查的是 url 的响应状态是否为 200:/Sites/testsite/api/level1/status/auth-service-health-check
问题就在这里
- contains:
- 200
subject: status-code
如果我这样添加,这个错误就消失了,但它会检查响应正文而不是状态代码
- contains:
- '200'
subject: status-code
您是否尝试过将 subject
更改为 http-code
?:
subject: http-code
检查 http-code 而不是 status-code 的建议是正确的。要对此进行扩展,请查看此处的解释: https://gettaurus.org/docs/JMeter/#HTTP-Requests
向下滚动一点,可以看到有关断言在 Taurus 中的确切工作原理的讨论,以及一些示例。特别要注意的是这部分:
Possible subjects are:
body
headers
http-code