Forum Discussion

Claire_Kaplan's avatar
Claire_Kaplan
Occasional Contributor
16 years ago

[SOLVED]How can we set values for a property in Data Source from Groovy Script?

I have a Data source using Grid. This has 2 rows in it with the property name as 'RefId'.

What I want to do is set the values for 'RefId' for the two rows using Groovy script.

How can we do this?
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi Claire,

    please try

    def model = testRunner.testCase.testSteps["DataSource"].dataSource.gridModel
    model.setValueAt( "1", 0, 0  )
    model.setValueAt( "2", 1, 0 )

    Does that work ok?

    regards!

    /Ole
    eviware.com
  • Claire_Kaplan's avatar
    Claire_Kaplan
    Occasional Contributor
    Hi

    Is there a way I can get the values at a cell location in the data source?

    I tried

    def model = testRunner.testCase.testSteps["DataSource"].dataSource.gridModel
    model.getValueAt( 0, 0  )

    but it did not work.

    Regards
    Shalabh
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    the gridModel is a standard swing TableModel so getValueAt( row, column ) should work just fine.. in what way did it not work for you?

    regards!

    /Ole
    eviware.com
  • Claire_Kaplan's avatar
    Claire_Kaplan
    Occasional Contributor
    Hi

    I am using it in Script assertion. It does not work there.
    It work in Groovy Script though.

    Regards
    Shalabh
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    ah.. in a script assertion you do not access to the testRunner, you need to use

    def model = messageExchange.request.testStep.testCase.testSteps["DataSource"].dataSource.gridModel
    model.getValueAt( 0, 0  )

    instead.. does that help?

    regards,

    /Ole
    eviware.com