This tutorial is the final step in Creating a Test Automation framework with C#, Selenium Webdriver 3 and Nunit. After Creating a functional testing flow with multiple test cases in the previous tutorial, we’ll now learn how to use data driven with Selenium test suite to add data driven support to the framework.
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#
- How to Create a Test Suite in Selenium WebDriver and C#
- You’re here→How to Use Data Driven with Selenium Test Suite
Let’s implement data driven with Selenium for the automated tests execution: Create a CSV file and enter the following lines of data:
test1;[email protected];Test 123;Hello from Csv File
test2;[email protected];Test 123;Hello from Csv File
Each line is the information the website’s form will receive (in our example: Contact Us), meaning our test will fill in the form twice, each time clicking on the Submit button and right away filling in the the next line.
We’ll be opening the Contact Us class, created here and paste the following function:
public void filldatafromCsv() { string filePath = @"C:\Users\TestProject\Desktop\runFile.csv"; List<string> data = new List<string>(); data = Servers.general.loadCsvFile(filePath); for (int i = 0; i < data.Count ; i++) { var values = data[i].Split(';'); SendYourName(values[0]); SendYourEmail(values[1]); SendYourSubject(values[2]); SendYourMessage(values[3]); clickSubmit(); ValidateMessage(); } }
This function’s purpose is to:
- Loading the file and its data.
- Fill out the form fields
- Click on Submit
- Verify the message has been sent successfully
The function will run once for every line of data in the CSV file.
Congratulations! In case you have been following all the tutorials for Creating a Test Automation framework , now you’ve created a test automation framework with C#, multiple browser support, Selenium WebDriver 3, Page Object Pattern and added support for data driven with Selenium.
Please leave a comment and let us know if you have any recommendations or questions!
thank you for the lovely step-by-step instructions. Very well illustrated.
Thank you very much 🙂