0
votes

I'm developing a JMeter plugin which takes response of corresponding request and parse.

I want to add/remove/modify test elements(like HTTPsamplers, Postprocessors, visualizers etc.) for a JMeter test plan at runtime (not while load testing)using JMeter APIs. How it will achieve in JMeter ?

Does anyone know JMeter API to add/remove/modify test elements ?

I have Googled my problem and not found any good solution and found a solution which modify jmx file (JMeter test plan file) using xml parser APIs , but it doesn't affect test plan behaviour at JMeter run time.

Ultimately, what I am trying to do is add/remove/modify test elements in in the current running test plan(not while loading).


Is this possible?




Thanks in advance.. :)

3
I googled and found GuiPackage.getInstance().getTreeModel().addComponent() API. Will it help ?Nithin CV

3 Answers

1
votes

I'm pretty sure you cannot do this. It would be better to determine first in which situations you would take a different path through your web application. Based on that you can put together a test plan with Switch/Interleave/Random controllers so you can take a different path.

Also there are post processors that you can use to parse responses and script your own functions so you can base your input for the next request on that.

I don't see why you would have to put together a test plan at runtime?

0
votes

Ok so there is no way to do what you are asking. The Test plan cannot be modified at run time.

I'd go back to the drawing board and restructure you tests.

As mentioned use Post and Pre Processors. Also maybe use IF Controllers to define different paths your tests take.

If you need more info just let us know!

Good luck! Phil

0
votes

At last I got the answer to add an element,

GuiPackage guiInstance = GuiPackage.getInstance();

TestElement testElement = guiInstance.createTestElement("org.apache.jmeter.XXXX.XXX.GUI_CLASS");

testElement.setName("TEST ELEMENT NAME");

JMeterTreeNode parentNode = guiInstance.getCurrentNode();

JMeterTreeNode node = guiInstance.getTreeModel().addComponent(testElement, parentNode);

guiInstance.getMainFrame().getTree().setSelectionPath(new TreePath(node.getPath())); 
guiInstance.updateCurrentGui();

Thanks for help.