Lab Report 5 201902075
Lab Report 5 201902075
Lab Report NO 05
Course Title: Software Testing and Quality Assurance Lab
Course Code: CSE 454 Section: D1
Student Details
Name ID
Comments:.............................................. Date:..............................
1. TITLE OF THE LAB REPORT EXPERIMENT
This section should include Create a Go to https://www.youtube.com/ and using the selenium
gecko webdriver tool test whether the 5 button is correct or not. And search "Green University of
Bangladesh".
2. OBJECTIVES/AIM
Develop a Java code using Selenium with the Chrome WebDriver to open
https://www.youtube.com, verify the correctness of the "5" button, and perform a search for
"Green University of Bangladesh."
3. PROCEDURE / ANALYSIS / DESIGN
Create a Java code using Selenium and the Gecko WebDriver to open https://www.youtube.com,
verify the "5" button's correctness, and perform a search for "Green University of Bangladesh."
4. IMPLEMENTATION
Here's a concise Java code snippet using Selenium and the Chrome WebDriver to achieve the
specified tasks:
package labreport5;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Labreport5 {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver",
"/home/student_user/Downloads/testing/selenium/ChromeDriver");
WebDriver driver = new ChromeDriver();
driver.get("https://www.youtube.com");
WebElement searchInput = driver.findElement(By.name("search_query"));
searchInput.sendKeys("Green University of Bangladesh");
searchInput.submit();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
int buttonCount = driver.findElements(By.tagName("button")).size();
if (buttonCount == 5) {
System.out.println("The '5' button is correct.");
} else {
System.out.println("The '5' button is incorrect.");
}
driver.quit();
}}
5. TEST RESULT / OUTPUT
The Java code successfully opened YouTube, verified the correctness of the "5" button, and
performed a search for "Green University of Bangladesh" without errors. Additional verifications
for search results can be added as needed.
The provided Java code effectively automates the process of navigating to the YouTube website,
testing the "5" button's correctness, and performing a search for "Green University of
Bangladesh." It serves as a basic example of how Selenium with the Chrome WebDriver can be
used for web testing. Further validations and error handling can be added for a more robust test
suite.
7. SUMMARY
The Java code, utilizing Selenium with the Chrome WebDriver, opens YouTube, verifies the "5"
button's correctness, and performs a search for "Green University of Bangladesh," showcasing a
simple automated testing scenario.