Write A Selenium Test Case with Multiple Verification Points

Write A Selenium Test Case with Multiple Verification Points

Write A Selenium Test Case with multiple verification points, Select Manual test case, Inspect HTML elements, get unique locators for elements, perform actions on the web elements using Selenium WebDriver methods, and enhance the test case using Java programming.

Manual Test Case:

Verify page redirecting functionality (from Admin Interface to User Interface) in gcrShop application.

Business Rule: It has to redirect from Admin to User interface, before admin login, and after admin login.

Test Steps:

1. Launch Browser
2. Navigate to Admin interface of the application (http://gcreddy.com/project/admin/login.php)
3. Click “Online Catalog” link
4. Capture the current URL
5. Back to previous page
6. Enter valid Username
7.Enter valid Password
8. Click Login button
9. Capture the current URL
10. Click “Online Catalog” link
11. Capture the current URL
12. Close Browser window

Verification Points:
1. Verify page redirecting functionality from admin to user interface before login
2. Verify page redirecting functionality from admin to user interface after login

Input / test data:
Username: gcreddy
Password: Temp@2020

Expected:
1. http://gcreddy.com/project/
2. http://gcreddy.com/project/

Write Selenium WebDriver Test Case:

System.setProperty(“webdriver.chrome.driver”, “C:\\Users\\user\\Downloads\\chromedriver.exe”);
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();

driver.get(“http://gcreddy.com/project/admin/login.php”);

driver.findElement(By.linkText(“Online Catalog”)).click();
Thread.sleep(2000);
String url1 = driver.getCurrentUrl();
//System.out.println(url1);

if (url1.equals(“http://gcreddy.com/project/”)) {
System.out.println(“Before Login – Page is redirecting from admin to user interface – Passed”);
}
else {
System.out.println(“Before Login – Page is Not redirecting from admin to user interface – Failed”);
}

driver.navigate().back();
driver.findElement(By.name(“username”)).sendKeys(“gcreddy”);
driver.findElement(By.name(“password”)).sendKeys(“Temp@2020”);
driver.findElement(By.id(“tdb1”)).click();
Thread.sleep(2000);
String url2 = driver.getCurrentUrl();

if (url2.equals(“http://gcreddy.com/project/admin/index.php”)) {
driver.findElement(By.linkText(“Online Catalog”)).click();
}

String url3 = driver.getCurrentUrl();
//System.out.println(url3);

if (url3.equals(“http://gcreddy.com/project/”)) {
System.out.println(“After Login – Page is redirecting from admin to user interface – Passed”);
}
else {
System.out.println(“After Login – Page is Not redirecting from admin to user interface – Failed”);
}
driver.close();
}
}


selenium tutorial
Selenium Tutorial for Beginners
Steps for Writing Selenium Test Cases:

1. Selenium Manual Test Case for Automation.

2. Inspect HTML / Web Elements using any Browser developer tools

3. Identify Unique Locators for the Elements.

4. Write Selenium Test Steps using Element Locators and WebDriver Methods

5. Enhance Selenium Test Cases using Java Programming

Note: We use Testing Framework (TestNG/JUnit) Assert commands to insert verifications points, and define test Results.

Scope of Automated Testing:

Automated Test Case scope is very high than Manual Test Case, Usually, we insert one verification point for one Manual test Case, but in Automated Test case, we can insert multiple verifications.

Test tool is Software it can concentrate on multiple verifications points at a time, but Human users can’t concentrate on multiple verification points at a time, so we prefer one verification for a Manualtest Case.

Follow me on social media: