简体   繁体   English

无法在 JMeter 中看到响应正文,查看结果树侦听器

[英]Unable to see Response Body in JMeter, View Results Tree listener

When I run a Http Request, to a page that should return a response body (I know it's working because I already tried in Postman).当我运行 Http 请求时,应该返回响应正文的页面(我知道它正在工作,因为我已经在 Postman 中尝试过)。 When I execute the sampler it's sends a 200 OK code, but the response body in the View Results Tree Listener, is empty.当我执行采样器时,它会发送 200 OK 代码,但查看结果树侦听器中的响应正文为空。 Why does this happen?为什么会发生这种情况?

I use MAC OS, and I installed JMeter with Brew.我使用 MAC 操作系统,并使用 Brew 安装了 JMeter。 I've already tried to add the following information in the user.properties file:我已经尝试在 user.properties 文件中添加以下信息:

jmeter.save.saveservice.output_format=xml
jmeter.save.saveservice.response_data=true
jmeter.save.saveservice.samplerData=true
jmeter.save.saveservice.requestHeaders=true
jmeter.save.saveservice.url=true
jmeter.save.saveservice.responseHeaders=true

It looks like this:它看起来像这样:

在此处输入图片说明

The changes you've made don't have any impact onto View Results Tree listener output, they are only for .jtl results files. 您所做的更改对View Results Tree侦听器输出没有任何影响,它们仅适用于.jtl结果文件。

Try the following: 请尝试以下操作:

  1. Run your JMeter test in command-line non-GUI mode like 在命令行非GUI模式下运行JMeter测试,例如

     jmeter -n -t test.jmx -l result.xml 

    and open result.xml file with your faviourite text or XML viewer/editor. 并使用result.xml夹文本或XML查看器/编辑器打开result.xml文件。 You should see something like: 您应该看到类似以下内容:

     <?xml version="1.0" encoding="UTF-8"?> <testResults version="1.2"> <httpSample t="93" it="0" lt="93" ct="42" ts="1568029799118" s="true" lb="HTTP Request" rc="200" rm="OK" tn="Thread Group 1-1" dt="text" by="759" sby="139" ng="1" na="1"> <responseData class="java.lang.String">{ &quot;userId&quot;: 1, &quot;id&quot;: 1, &quot;title&quot;: &quot;delectus aut autem&quot;, &quot;completed&quot;: false }</responseData> <java.net.URL>http://jsonplaceholder.typicode.com/todos/1</java.net.URL> </httpSample> </testResults> 

    where responseData tag contains XML-escaped response data. 其中responseData标记包含XML转义的响应数据。 If there is some data in the file - most probably something is wrong with your JMeter installation, try re-installing it by downloading JMeter from the official website as the Brew package might be broken. 如果文件中有一些数据-很可能是您的JMeter安装出现问题,请尝试从官方网站下载JMeter来重新安装它,因为Brew软件包可能已损坏。

  2. Check jmeter.log file contents , if anything goes wrong JMeter normally writes a log message with the results. 检查jmeter.log文件的内容 ,如果有任何问题,JMeter通常会在日志消息中写入结果。

I had this exact issue, and the final answer was to use either Java version 9 or in my case it was Java version 8. That fixed the issue and I am now able to see the response body and response headers. 我遇到了这个确切的问题,最终的答案是使用Java版本9,或者我使用的是Java版本8。这解决了问题,现在我可以看到响应正文和响应标头。 在此处输入图片说明

I see you didn't load the generated *.jtl file in your "View results Tree" panel.我看到您没有在“查看结果树”面板中加载生成的*.jtl文件。 You should browse and open that file and then you can see the results.您应该浏览并打开该文件,然后您就可以看到结果。 Remember, you must add the listener, run the tests in non-GUI mode once, and the *.jtl file would then contain the results.请记住,您必须添加侦听器,在非 GUI 模式下运行一次测试,然后 *.jtl 文件将包含结果。 Open them here:在此处打开它们:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM