This is for a test automation using c# and Specflow (cucumber for c#)
I have a class with urls like this:
class Paths
{
public static string google_home = "www.google.com";
public static string another_url = "www.something.com";
public static string facebook_home = "www.facebook.com";
}
And I have a step definition like this:
[Then(@"I navigate to ""(.*)""")]
public void INavigateTo (string url)
{
Configuration.driver.Navigate().GoToUrl(Paths.url);
}
Of course this scrip doesnt work, but I just want to explain the idea. By using the step definition like this:
I navigate to "google_home"
I obtain the string "google_home", and I want to use this string to directly choose the option Paths.google_home. I dont want to use a switch to do the assignation, since there are hundreds of urls.
EDIT: The linked solution would be something like this:
var values = typeof(Paths).GetFields();
Configuration.driver.Navigate().GoToUrl(values[0].GetValue(null).ToString());
I have no idea of knowing what number of the array "values" corresponds with the string I am looking for. As such I dont consider it a solution.