How to get the Test Data File Location - Data Source URL?

I need to get the Data File name and location/url in code so I can write to it. I will be changing the Data File, so first I load File1 and complete running through all rows. Next I will run the same test for another client using File2. I might have a lot of files. When I am writing to the data file, I need to know the name of the file. The location of the file will be the same, but the files will have different names. As shown below, before each run, I will substitute this file with another one. So I need to get this location, so I can write to the appropriate file. I notice that the dat file, that is saved in DataFiles folder has a property dataSourceUrl, which has the filename location. I am trying to see how to access that info so we can use it in the code.
If anyone knows how to do it, please let me know. TIA.

You’ll need XMLSlurper

http://groovy-lang.org/processing-xml.html

I had a similar enough need to process Test Suites. This is the keyword method I wrote - it should give you enough of a head start…

  /**
   * Returns a string containing references to all Test Cases found in the
   * specified Test Suite.
   * <p>
   * Supports the <b>TestCase Lister</b> tool used for Test Case/Test Suite analysis.
   *
   * @param suiteName (String) The Test Suite to be examined.
   * @param before (String) Typically used to pass HTML to the output.
   * @param after (String) Typically used to pass HTML to the output.
   * @return String.
   */
  static String getSuiteTests(String suiteName, String before = "", String after = "") {
    int count = 0
    String projDir = RunConfiguration.getProjectDir()
    String fname = projDir + "/Test Suites/" + suiteName + ".ts"
    String xmlText = new File(fname).getText()
    def testList = new XmlSlurper().parseText(xmlText)
    String output = ""

    testList.testCaseLink.testCaseId.each {
      count++
      output += before + count.toString() + ": " + it.toString() + after + "\n\n"
    }
    return output
  }