Forum Discussion

shiv's avatar
shiv
New Contributor
9 years ago
Solved

How to parameterize or set the relative path for the location of data source as used for data-driven

Hi Community Experts,

 

I've a question on parameterization or set the relative path for the location of data source as being used for data-driven using excel in the Ready API 1.6.0.

 

Exp: Data Source Path: C:\Working Folder\Automation\Data\source.xls

 

Here how to make the relative path, so that if we shift the code to other machine, it should work without changing the data source location manually. Any other related workaround will also work.

 

Appreciate in advance for quick response

 

Thanks,

Shiv

  • You can use property expansion.

     

    For example:

    The project and its artifacts on your machine located at C:\Working Folder\Automation\Data\source.xls.

    That means, you have taken the project artifacts (Automation directory) from the repository to C:\Working Folder 

    However, it can be different location on a different computer or collegue's machine,  say D:\workspace. But the rest of the location is same which is why you wanted to refer to relative location.

     

    So, you can define a project level custom property, say PROJECT_ARTIFACTS_LOCATION and define value as  C:/Working Folder. Others can change the property value on their environment. Now, this works on any machine with just property value change.

     

    In the DataSource step, have the value for File as ${#Project#PROJECT_ARTIFACTS_LOCATION}/Automation/Data/source.xls.

     

    Note that you can't use browse button for this, just type in as above.

     

    Of course, it is not mandatory that you need to use Project level property alone. You are free to choose different level properties such as  TestSuite, TestCase or even projectDir (same location as soapui prject is located, for example, just use ${projectDir}/file.xls)

2 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3

    You can use property expansion.

     

    For example:

    The project and its artifacts on your machine located at C:\Working Folder\Automation\Data\source.xls.

    That means, you have taken the project artifacts (Automation directory) from the repository to C:\Working Folder 

    However, it can be different location on a different computer or collegue's machine,  say D:\workspace. But the rest of the location is same which is why you wanted to refer to relative location.

     

    So, you can define a project level custom property, say PROJECT_ARTIFACTS_LOCATION and define value as  C:/Working Folder. Others can change the property value on their environment. Now, this works on any machine with just property value change.

     

    In the DataSource step, have the value for File as ${#Project#PROJECT_ARTIFACTS_LOCATION}/Automation/Data/source.xls.

     

    Note that you can't use browse button for this, just type in as above.

     

    Of course, it is not mandatory that you need to use Project level property alone. You are free to choose different level properties such as  TestSuite, TestCase or even projectDir (same location as soapui prject is located, for example, just use ${projectDir}/file.xls)

  • The best answer for ur question was, create the data source as data generator, then this works where ever you want. not manually exporting the data from excel [If it works]