Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How to read datasource in Parasoft using scripting

Akanksha
Akanksha Posts: 3
edited October 2017 in SOAtest

Using script i want to read the values from datasource so that the same can be used across all TSTs.

Answers

  • Ireneusz Szmigiel
    Ireneusz Szmigiel Posts: 227 ✭✭✭
    edited October 2017

    Akanksha,

    you can use Global Data Source which allows you to use the same data source across all TSTs.
    Here is a simple Jython script which read column from data source called "Global" with column named "keyword":

        from com.parasoft.api import *
    
        def getDataSourceValue(input, context):
            # "value" is the value from the Data source at the specified column
            value = context.getValue("Global", "keyword")
            Application.showMessage("In DS we have:" + str(value))
    

    BTW: here is a good example how to get vale of particular row

  • Akanksha
    Akanksha Posts: 3

    Hi Ireneusz , Is it possible to achieve this using groovy scripting. Below is the script we are using:
    import static java.util.Calendar.*;
    import java.text.SimpleDateFormat;
    import javax.xml.datatype.XMLGregorianCalendar;
    import java.text.DateFormat;
    import java.util.regex.Pattern;
    import java.sql.Timestamp;
    import java.lang.*;
    import java.io.*;
    //def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context);

    String path(){
    def sdf = new java.text.SimpleDateFormat("dd-MM-yyyy hh-mm-ss aa");
    def SysDate = sdf.format( new Date()) ;

    String runFolder = "C:/User/Run_" + SysDate;

    def runFolderDir= new File(runFolder);
    runFolderDir.mkdir();

    return runFolder;
    }

    I have tried below groovy script in SoapUI and able to call datasource but the same script is not working in Parasoft.
    def getstep = testRunner.testCase.getTestStepByName("Properties").getPropertyValue("FolderPath");
    log.info getstep;

    I need to know how this can be called in parasoft.
    Thanks in advance!

  • Ireneusz Szmigiel
    Ireneusz Szmigiel Posts: 227 ✭✭✭

    Akanksha

    I think that soapUI script will not work as you are using part of soapUI api.
    Did you check thread which I mentioned at the end of my post?
    There is an example in Groovy:

    import com.parasoft.api.*;
    
    public String getFifth(ScriptingContext context)
    {
        return context.getValues("New Datasource", "test").get(4);
    }
    

    What do you want to do:
    -open datasource defined/exist in SOAtest project?
    -open external file in SOAtest as datasource?

  • Akanksha
    Akanksha Posts: 3

    I want to read values defined in datasource in Parasoft SOA Project

  • Ireneusz Szmigiel
    Ireneusz Szmigiel Posts: 227 ✭✭✭

    Then you can use steps described in this topic.