I have a Selenium test where I am filling in a web form. The test works but as part of the test validation I currently call a method to return a string multiple times.
//Variables stored in appsettings.json file
string ServiceName = _configuration[Configuration.EnvConfig + ":NewService"];
string VendorName = _configuration[Configuration.EnvConfig + ":NewVendor"];
string RelationshipManager = _configuration[Configuration.EnvConfig + ":RelationshipManager"];
// Date is stored in configuration class so that it can be passed to other class files for validation
private static string thisDay = Configuration.currentDate.ToString();
public string NewVendorName()
{
string NewVendorName = thisDay + VendorName;
return NewVendorName;
}
public string NewServiceName()
{
string NewServiceName = thisDay + ServiceName;
return NewServiceName;
}
I use these two methods in the majority of my tests and am calling them in multiple methods within those tests as part of my validation.
I’ve tried using a get set but have not been able to get that to work because of the non-null values.
I also tried setting the strings coming from appsettings.json to ‘private static’ but get an error at runtime.
//Variables stored in appsettings.json file
private static string ServiceName = _configuration[Configuration.EnvConfig + ":NewService"];
private static string VendorName = _configuration[Configuration.EnvConfig + ":NewVendor"];
private static string RelationshipManager = _configuration[Configuration.EnvConfig + ":RelationshipManager"];
// Date is stored in configuration class so that it can be passed to other class files for validation
private static string thisDay = Configuration.currentDate.ToString();
string NewVendorName = thisDay + VendorName;
string NewServiceName = thisDay + ServiceName;
I am looking for insight on the best way to implement this without having to call the same two methods over and over but am at a loss.
3