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 get current data source row number?

Parasofttoudaya
Parasofttoudaya Posts: 232 ✭✭
edited September 2017 in SOAtest

Hi Team,

I came across a situation where i need to get data source current row number in xpath reg-ex.
Let me know how to fetch it??

Thanks
Udaya

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    See com.parasoft.api.ScriptingContext.getDataSourceRowIndex(). You'll have to call this from a script or Extension Tool. Your script could store the value into a test suite variable using ScriptingContext.setValue(String variableName, String value) and then your XPath can reference the variable using ${varName}.

  • Parasofttoudaya
    Parasofttoudaya Posts: 232 ✭✭

    Thanks Ben

    Thanks a lot for immediate response..

    Regards
    Udaya

  • Parasofttoudaya
    Parasofttoudaya Posts: 232 ✭✭

    I am getting -1 always :(

    public void message(Object input, ScriptingContext context){
    Application .showMessage(context.getDataSourceRowIndex())
    }

    its always returning -1.

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭
    edited September 2017

    In your Extension Tool, did you enable the "Use data source" box? Is the correct data source selected in the "Data Source" combo?

  • Parasofttoudaya
    Parasofttoudaya Posts: 232 ✭✭

    It did worked, good guess. Thanks

  • reactancexl
    reactancexl Posts: 160

    does anyone know what syntax is used for Jython on this?

  • jakubiak
    jakubiak Posts: 795 admin
    from com.parasoft.api import *
    
    def getRow(input, context):
        Application.showMessage(str(context.getDataSourceRowIndex()))