Thank you so much, the code below resolved my problem

Yevgeniy Grimaylo
Staff QA Member
Synopsys
(617) 2854671
20 Park Plaza, Suite 1400
Boston, MA 02116

On 10/25/17, 12:45 PM, "Philippe Mouawad" <philippe.moua...@gmail.com> wrote:

    Did you try:
    beanshell.setProperty(BeanShellSampler.SCRIPT, "script code");
    
    By the way, you shouldn't be using Beanshell anymore and look at migrating
    to JSR222 + Groovy + Cache.
    
    Regards
    
    On Wed, Oct 25, 2017 at 5:26 PM, Yevgeniy Grimaylo <
    yevgeniy.grima...@synopsys.com> wrote:
    
    > Hello,
    > I am trying to create jmeter jmx file at run time by using jmx api in java
    > I have the following code, which should create BeanShell Sampler gui
    > config element with the BeanShell Sampler name, comments and script itself
    > But, after script execution, I open generated by java jmx file, I noticed
    > that only BeanShell Sampler name and comments are shown, but not Script
    > So, my question is: how can I create BeanShell Sampler GUI Config element
    > with actual script shown under  Script Area ?
    > I am using jmeter jmx api version 3.3 and java 1.8
    > Java code fragment:
    > BeanShellSampler beanshell = new BeanShellSampler();
    > beanshell.setName("BeanShell Sampler");
    > beanshell.setComment("This is beanshell sampler");
    > beanshell.setScript("BeanShell scripting goes here");
    > beanshell.setEnabled(true);
    > beanshell.setProperty(TestElement.TEST_CLASS, BeanShellSampler.class.
    > getName());
    > beanshell.setProperty(TestElement.GUI_CLASS, BeanShellSamplerGui.class.
    > getName());
    > // Test Plan
    > TestPlan testPlan = new TestPlan(testPlanName);
    > testPlan.setEnabled(true);
    > testPlan.setProperty(TestElement.TEST_CLASS, TestPlan.class.getName());
    > testPlan.setProperty(TestElement.GUI_CLASS, TestPlanGui.class.getName());
    > testPlan.setUserDefinedVariables((Arguments) new ArgumentsPanel().
    > createTestElement());
    > // Construct Test Plan from previously initialized elements
    > testPlanTree.add(testPlan);
    > HashTree threadGroupHashTree = testPlanTree.add(testPlan, threadGroup);
    > threadGroupHashTree.add(beanshell);
    >
    >
    > Thanks in advance for your feedback
    > Yevgeniy Grimaylo
    > Staff QA Member
    > Synopsys
    > (617) 2854671
    > 20 Park Plaza, Suite 1400
    > Boston, MA 02116
    >
    
    
    
    -- 
    Cordialement.
    Philippe Mouawad.
    

Reply via email to