0% found this document useful (0 votes)
39 views5 pages

STB Lab3

Uploaded by

Abhishek Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views5 pages

STB Lab3

Uploaded by

Abhishek Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Name:

Enrolment Number:
Batch:
Name- Abhishek Yadav
Enrollment No- 22000215
Batch- A

Navrachana University

CMP402 (Software Testing Basics)


Lab File: 3

Introduction To Selenium Web Driver

Q1. Develop a test case document in excel for “www.google.com” for different browsers
i.e Chrome, Safari, IE, Edge and Firefox.

Input :
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chromium.ChromiumDriver;
import org.openqa.selenium.edge.EdgeDriver;

public class Practical3{

public static void main(String[]args) {


ChromiumDriver driver = new EdgeDriver();
driver.get("https://www.google.com");
driver.findElement(By.id("APjFqb")).sendKeys("hi");

driver.findElement(By.xpath("/html/body/div[1]/div[3]/form/div[1]/div[1]/di
v[4]/center/input[1]")).click();
}
}

Output :

1
Name:
Enrolment Number:
Batch:

Excel :

2
Name:
Enrolment Number:
Batch:

Q2. Develop a test case document in excel for “www.google.com” for a browser using if
else condition by taking user’s input.

Input :
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.Scanner;
public class practical3_2 {
public static void main(String[] args) {
System.out.println("Enter the browser choice (Chrome, Edge, or
Firefox):");
Scanner sc = new Scanner(System.in);
String choice = sc.nextLine();
WebDriver driver = null;
if (choice.equalsIgnoreCase("Chrome")) {
driver = new ChromeDriver();
} else if (choice.equalsIgnoreCase("Edge")) {
driver = new EdgeDriver();
} else if (choice.equalsIgnoreCase("Firefox")) {
driver = new FirefoxDriver();
} else {
System.out.println("Invalid browser choice. Please choose
Chrome, Edge, or Safari.");
System.exit(0);
}
driver.get("http://www.google.com");
driver.findElement(By.id("APjFqb")).sendKeys("selenium");
driver.findElement(By.xpath("/html/body/div[1]/div[3]/form/div[1]/div[1]/di
v[4]/center/input[1]")).click();
driver.close();
}
}

Output :

3
Name:
Enrolment Number:
Batch:

4
Name:
Enrolment Number:
Batch:

Excel :

You might also like