Write Selenium Data Driven Test Case

Write Selenium Data Driven Test Case

Write Selenium Data Driven Test Case, Inspect HTML Elements, Identify unique locators for Web elements, and perform actions on the web elements using Selenium Webdriver methods.
Prerequisites for Writing Selenium Test Cases, Manual Test Case, Element Locator for locating elements in web pages, Selenium WebDriver API commands for performing actions on the AUT, and programming features for enhancing Selenium test cases.
What is Data-Driven Testing?, Why Data-Driven Testing, How to conduct data-driven testing, and Writing Selenium Data-Driven Test cases.
selenium tutorial
Selenium Tutorial for Beginners
What is Data Driven Testing?

Executing a Test case using multiple sets of data.

Why Data Driven Testing?
Data driven testing is for conducting Positive and Negative Testing.

Difference between Parameterization and Data Driven Testing?
For passing a single value or multiple values we use Parameterization, we use multiple values only for Data driven testing.

How to conduct Data Driven Testing?
By using any resource (Test Data file) we can conduct Data driven testing.

Steps for Data Driven Testing:
1. Read Test Data from an external file
2. Create a Test case
3. Connect Test data with the Test case

Manual Test Case:

Test Case Name: Data Driven Testing for admin login functionality by reading test data from a text file

Test Steps:

1. Launch Browser

2. Navigate to gcrShop application Admin interface home page

3. Enter Username

4. Enter Password

5. Click OK Button

Verification Point:

Capture the current URL after click on the Login Button, and compare it with expected.

Input/Test data:

Ref: input.txt

Selenium Data Driven Test Case

System.setProperty(“webdriver.chrome.driver”, “C:\\Users\\user\\Downloads\\chromedriver.exe”);

FileReader fileObject = new FileReader(“C:\\Users\\user\\Desktop\\input.txt”);
BufferedReader br = new BufferedReader(fileObject);
String line;
int lineCount=0;
int Iteration=0;

while ((line = br.readLine()) !=null) {
String inputData [] = line.split(“, “, 2);

if (lineCount>1) {

WebDriver driver = new ChromeDriver();

String url= driver.getCurrentUrl();

if (url.equals(“https://gcreddy.com/project/admin/index.php”)) {
System.out.println(Iteration + ” Admin Login is Successful – Passed”);
else {
System.out.println(Iteration+” Admin Login is Unsuccessful – Failed”);

Follow me on social media: