logo logo

How to Create a Test Suite in Selenium WebDriver and C#

main post image

After completing the test automation framework we’ve developed with Selenium, c# and Nunit, with the following quick tutorial you’ll learn to create a test suite in Selenium WebDriver.


 

Tutorial Overview:

Class 1 – Creating an Automated Test Using Selenium WebDriver 3 and C#

Class 2 – How to Create a Test Automation Framework Architecture with Selenium WebDriver 3

Class 3 – Utilizing Test Automation Framework with Advanced Capabilities


To begin, we will copy the test below in our test automation project:

[Test]
public void ContactUsTestflow()
{
    Pages.contactUs.Goto();

    Assert.IsTrue(Pages.contactUs.isAt());

    Pages.contactUs.SendYourName("Asya test");
    Pages.contactUs.SendYourEmail("[email protected]");
    Pages.contactUs.SendYourSubject("Test");
    Pages.contactUs.SendYourMessage("Test 123");
    Pages.contactUs.clickSubmit();
    Pages.contactUs.ValidateMessage();
}

First, we’ll order Selenium to navigate to the Contact Us page we are testing. Secondly, assert that we are at the correct page by asking our browser for the title of the page and asking if the url consists of the wording ‘contactUs’. Afterwards, we’ll fill out the relevant fields, click Submit and verify the message has been sent successfully.

  • This method is also valid for building an alignment of sanity testing for our website.

 


In the next tutorial to Create a test automation framework, you will learn How to Use Data Driven with Selenium Test Suite.

Feel free to leave your questions/ideas in the comment section below!


 

Asya Galinsky

About the author

Asya Galinsky

Join TestProject Community

Get full access to the world's first cloud-based, open source friendly testing community. Enjoy TestProject's end-to-end test automation Platform, Forum, Blog and Docs - All for FREE.

Join Us Now  

Comments

9 3 comments
  • Avatar
    rose_123 May 4, 2018, 5:28 pm

    Hi,
    Thanks for this tutorial. It was very helpful! I have a question for you though. Pagefactory is going to be deprecated very soon. Can you please show us how to modify the existing code in your tutorial based on that? I am asking about these specific lines:
    private static T getPages() where T : new ()
    {
    var page = new T();
    PageFactory.InitElements(Browsers.getDriver, page);
    return page;
    }

    • Oren Nahum
      Oren Nahum May 13, 2018, 5:34 pm

      Why would you say PageFactory is going to be deprecated?
      For some projects perhaps. For others it is quite useful.

      In any case, even if C# will deprecate its PageFactory lib, you can still implement it yourself

      private static T getPages() where T : new ()
      {
      var page = new T();
      PageFactory.InitPages(Browsers.getDriver, page); // replace this with your own method to initialize your pages.
      return page;
      }

      private static void InitPages()
      {
      loginPage = new LoginPage(); // class member

      }

      • Avatar
        srinivaskassa January 9, 2020, 7:34 am

        Can you please explain how to create suite to using selenium with C# (Visual Studio)
        I am using Selenium,C# and NUnit and editor is Visual Studio and created 50 test cases (.cs). Now, I need to create multiple suites like each suite contains 2 or more .cs (test cases)
        Kindly provide detailed information. Thanks in advance, Srinivas

Leave a Reply

Join TestProject Newsletter

Join a 20K community of readers! Always stay up-to-date with all the latest test automation trends, best practice and tips shared by leading software testing community experts across the globe!

FacebookLinkedInTwitterEmail