I have a list of URLs in an Enum. I would like to pass the enum value as a parameter to my method and use it to browse to the URL using Selenium Web driver.
Error CS0029 Cannot implicitly convert type 'string' to 'automation.Enums.UrlEnums.Url' automation F:\Projects\C#\automation\Helpers\NavigateHelper.cs 22 Active
My code snippet is:
public class UrlEnums
{
public enum Url
{
[Description("https://www.companysite1.com")]
company1,
[Description("https://www.companysite2.com")]
company2
}
}
public void NavigateTo(UrlEnums.Url url)
{
switch (url)
{
case "Thriller":
Driver.Navigate().GoToUrl(url);
//Driver.Navigate().GoToUrl("https://www.companysite1.com");
break;
case "Comedy":
Driver.Navigate().GoToUrl(url);
break;
}
}
How do I use the enum to pass as a parameter and go to the URL? This list of Enums will grow and have more URLs soon.
My SpecFlow Scenario is:
Feature: WelcomePage
In order to view the film categories
As a user I should be able to click on a category
I should see the welcome page for the selected category
@smoke
Scenario Outline: NavigateToFilmCategory
Given I navigate to <Category> page
Then I should see the welcome page <WelcomePage>
Examples: TestData
| Category | WelcomePage |
| Thriller | Thriller Films |
| Comedy | Comedy Films |
| Action | Action Films |
| Adventure | Adventure Films |
Thanks,