I am building a testing framework, my objective is to test many websites that have similar pages with light difference between each other using this framework.
I have an issue where I want WebElements Selectors to be dynamic, which means that I want to pass the way I want to find the element as a parameter to FindElement method.
I am trying to build something like this:
public class WebComponent
{
public int ID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public IWebElement WebElement{get;set;}
public Accessor Accessor { get; set; }
public WebComponent()
{
Accessor = new Accessor();
}
}
public class Accessor
{
OpenQA.Selenium.By By { get; set; }
public string Value { get; set; }
}
And later in my code when I want to have instance of this class:
WebComponent component = new WebComponent();
component.ID = 1;
component.Name = "Logout Button";
component.Description = "The button to click when user wants to logout of website";
component.Accessor.By = By.Id;
component.Accessor.Value = "logout";
component.WebElement = Browser.Driver.FindElement(//missing code);
My question is how can I find the WebElement using component.Accessor, any advice or suggested edits will be much appreciated.