I have tried:
我努力了:
//${__FileToString(C:\\QC\\qa\\Testlink\\Jmeter\\Expected\\test.xml,ASCII,${xmlFile})};
//${__FileToString(C:\\QC\\qa\\Testlink\\Jmeter\\Expected\\test.xml,ASCII,${xmlFile})};
Found error message : org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval In file: inline evaluation of: ``//<?xml version="1.0" encoding="UTF-8"?> <feed xmlns="http://www.w3.org/2005/At . . . '' Encountered "<" at line 2, column 1.
发现错误消息:org.apache.jorphan.util.JMeterException:调用bsh方法时出错:eval文件:内联评估:``// <?xml version =“1.0”encoding =“UTF-8”?>
also, I tried with ${__StringFromFile}
and got the same error message and even with beanshell script that is:
另外,我尝试使用$ {__ StringFromFile}并得到相同的错误消息,甚至使用beanshell脚本:
import org.apache.jmeter.services.FileServer;
//Open the file
FileInputStream fstream = new FileInputStream("C://QC//qa//Testlink//Jmeter//Expected//test.xml");
//Get the object of DataInputStream
DataInputStream instream = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(instream));
1 个解决方案
#1
3
Try out the following:
试试以下内容:
- Add Beanshell Sampler to your Test Plan
- 将Beanshell Sampler添加到您的测试计划中
-
Put the following code into the sampler's "Script" area:
将以下代码放入采样器的“脚本”区域:
import org.apache.commons.io.FileUtils; try { String content = FileUtils.readFileToString(new File("C:/QC/qa/Testlink/Jmeter/Expected/test.xml")); vars.put("content", content); } catch (Throwable ex) { log.info("Failed to read \"test.xml\" file", ex); throw ex; }
-
Add Debug Sampler and View Results Tree listener to your Test Plan
将Debug Sampler和View Results Tree监听器添加到测试计划中
- Run the test
- 运行测试
- Make sure that Beanshell Sampler is green and
${content}
variable is set. If not - look into jmeter.log file and search for the lineFailed to read "test.xml" file
. If exception stacktrace below this line tells you nothing - post it here. - 确保Beanshell Sampler为绿色且设置了$ {content}变量。如果不是 - 查看jmeter.log文件并搜索无法读取“test.xml”文件的行。如果此行下面的异常堆栈跟踪告诉您什么 - 在此处发布。
See How to Use BeanShell: JMeter's Favorite Built-in Component guide for more information on using Beanshell in your JMeter test.
有关在JMeter测试中使用Beanshell的更多信息,请参见如何使用BeanShell:JMeter最喜欢的内置组件指南。
#1
3
Try out the following:
试试以下内容:
- Add Beanshell Sampler to your Test Plan
- 将Beanshell Sampler添加到您的测试计划中
-
Put the following code into the sampler's "Script" area:
将以下代码放入采样器的“脚本”区域:
import org.apache.commons.io.FileUtils; try { String content = FileUtils.readFileToString(new File("C:/QC/qa/Testlink/Jmeter/Expected/test.xml")); vars.put("content", content); } catch (Throwable ex) { log.info("Failed to read \"test.xml\" file", ex); throw ex; }
-
Add Debug Sampler and View Results Tree listener to your Test Plan
将Debug Sampler和View Results Tree监听器添加到测试计划中
- Run the test
- 运行测试
- Make sure that Beanshell Sampler is green and
${content}
variable is set. If not - look into jmeter.log file and search for the lineFailed to read "test.xml" file
. If exception stacktrace below this line tells you nothing - post it here. - 确保Beanshell Sampler为绿色且设置了$ {content}变量。如果不是 - 查看jmeter.log文件并搜索无法读取“test.xml”文件的行。如果此行下面的异常堆栈跟踪告诉您什么 - 在此处发布。
See How to Use BeanShell: JMeter's Favorite Built-in Component guide for more information on using Beanshell in your JMeter test.
有关在JMeter测试中使用Beanshell的更多信息,请参见如何使用BeanShell:JMeter最喜欢的内置组件指南。