Forum Discussion

sanj's avatar
sanj
Super Contributor
7 years ago

Data driven tests- How to clear data when using grid?

How would I clear data when using data grid for DDT or data driven tests?

Seems like the only way is to un-select the column

I try the icon with erase which says clear data but that does not work!

 

also why does it keep having one blank being selected?

This sounds like a bug even if I un-select that blank row it will select the one below that.

 

I have attached screenshot

 

5 Replies

  • groovyguy's avatar
    groovyguy
    Champion Level 1

    If you need to delete data from the entire grid datasource, you an use a groovy script to clear it out the rows. Warning: this will make your grid 100% empty.

     

    def grid = testRunner.testCase.testSteps["DataSource"].dataSource.gridModel
    int rows = grid.getRowCount();
    log.info(rows);
    for (int i = 0; i < rows; i++)
    {
    	log.info(i);
    	grid.deleteRows(0);
  • nmrao's avatar
    nmrao
    Champion Level 3
    Check the data file if there are empty lines in the end of the file.
  • People sure like to use Groovy to solve what already has a UI element for it :) Unless you want to modify it during the test run of course.

     

    The blank line at the end is a UI element so that its easier to create new rows and does not affect your tests. Its just there to make adding a new row quicker.

    • groovyguy's avatar
      groovyguy
      Champion Level 1

      IgorG: I tend to use a grid DataSource to house data that changes every time I run a specific sort of tests. I work a lot with groovy to try to automate what I can with testing. :smileyhappy:

      • sanj's avatar
        sanj
        Super Contributor

        I am trying to get into groovy because I am seeing limits where I need to take a more automated approach