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#
- Setting Up the Development Environment for Your Selenium Automation Framework
- How to Inspect Web Elements & Methods to Locate Them with Chrome Devtools
- How to Find Web Elements with Selenium WebDriver
Class 2 – How to Create a Test Automation Framework Architecture with Selenium WebDriver 3
- How to Create a Cross Browser Compatible Testing Framework
- Steps to Develop a Report Module in a Testing Framework
- Implementing a Report Module in an Automated Framework
- How to Write a Functional Test with a Basic Selenium Automation Framework
Class 3 – Utilizing Test Automation Framework with Advanced Capabilities
- Page Object Pattern: Advantages & Implementation
- Read Data From CSV File in C#
- You’re here→How to Create a Test Suite in Selenium WebDriver and C#
- How to Use Data Driven with Selenium Test Suite
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!
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;
}
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
…
}
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