Refactor Automation Framework To Work With Multi Browsers
<p>Posting here as my googling and searching stackoverflow hasn't given me quite what I am looking for. So, hopefully someone here can point me in the right direction or give me some pointers on how to solve my issue.</p>
<p>Preface: I have been teaching myself C#/.net for a little over a year now and still consider myself a novice. But in that time I have gone from a manual software tester to getting myself my first job as an Automation Engineer.</p>
<p>I've currently built a framework using Selenium Webdriver and the page object model framework. And the issue I have is currently my framework ideally only allows for one browser at a time. I could have different browsers being used at the same time, but i'd have to have the multiple versions of the test too.</p>
<p>Below is an example of how my framework is currently. As I'd imagine this would help.</p>
<pre><code>public class WebDriver
{
  public static IwebDriver driver;
}
</code></pre>
<p>Then this is inherited by my TestBase class, which is attached to each test</p>
<pre><code>public class TestBase: WebDriver
{
    public TestContext TestContext { get; set; }

    [TestInitialize]
    public void Initialize()
    {
        Driver = new ChromeDriver();
    }

    [TestCleanup]
    public void Cleanup()
    {
        //Company specific cleanup logic
        //Reporting Etc. 
        Driver.Quit();
    }
}
</code></pre>
<p>This base class is then inherited by each test class; seen below.</p>
<pre><code>[TestClass]
public class LoginTests : TestBase
{
    [TestMethod]
    public void SuccessfulLogin()
    {
        LoginPage login = new LoginPage();
        login.NavigateToLogInPage();
        HomePage homePage = login.LoginWithCorrectDetails();
        homePage.LogoutFromHomePage();
    }
}
</code></pre>
<p>What I was planning on doing was having a &quot;Testbase&quot; class for each browser (Chrome, firefox, IE) and would then have a version of each test, that would inherent a browser.</p>
<p>So, in the example below there would be</p>
<blockquote>
<p>SuccessfulLogin: Chrome</p>
<p>SuccessfulLogin: FireFox</p>
<p>SuccessfulLogin: IE</p>
</blockquote>
<p>While this would would, (I did a short test), it's far from ideal and I can imagine will cause various issues later on down the line.</p>
<p>What I'm looking for is help/direction in which I only have one version of my test and my framework is intelligent enough to run it on all browsers.</p>