Passing varible values into repository variables

Ask general questions here.
Posts: 10
Joined: Wed Feb 11, 2015 5:36 pm

Passing varible values into repository variables

Post by mtaylor » Fri Oct 14, 2016 4:23 pm

Right now there seems to be no way to pass a value into a variable in the repository except by the default value this true like what if I wanted to have a dynamic variable for my base dom path

Path -> Base: /dome[@domain=$Hostname]

is really the only way to pass the $hostname into this is by the default value???

I have written a piece of code here to do it by module level...but I need a global setting for the repository.

Code: Select all

public static void setCommonRepositoryHostname()
			string globalParamOverridePath = "C:\\Users\\Public\\workspace\\Resource\\global-parameters-override.csv";
			var GlobalParamOverrideCsv = new FileInfo(globalParamOverridePath);
			string path = "C:\\Users\\Public\\workspace\\Resource\\global-parameters.csv";
			if (GlobalParamOverrideCsv.Exists)
				path= globalParamOverridePath;			
			IEnumerable<string> linesEnumerable = File.ReadLines(path);
			string [] lines = linesEnumerable.ToArray();
			string [] columns = lines[0].Split(',');
			int hostnameColumnIndex = 0;
			for(int i = 0; i < columns.Length; ++i)
					hostnameColumnIndex = i;
			string domain = lines[1].Split(',')[hostnameColumnIndex].Trim();
			Common.CommonRepository repo = Common.CommonRepository.Instance;
			repo.Hostname = domain;

Posts: 31
Joined: Fri Nov 27, 2015 11:32 am

Re: Passing varible values into repository variables

Post by bygones » Mon Oct 17, 2016 7:49 am

not sure if this is matches your problem, I have a web application, which uses also a variable in the repository as the url to the application might be different in different context.

So I have /dom[@domain=$host_server] as root in my repository.

On the test suite level I have a global parameter host_server with a default value. Then in the recording modules again, I have a variable host_server - and all are bound to each other.

Now I can start the application either by passing no value in, then the default value is taken, or with a specific value for host_server, so that value is taken