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

Testing Lab

The document contains two test cases for login functionality using Selenium WebDriver. The first test case verifies successful login with valid credentials, while the second test case checks for error handling with invalid credentials. Both tests utilize the Firefox browser and include assertions to compare expected and actual outcomes.

Uploaded by

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

Testing Lab

The document contains two test cases for login functionality using Selenium WebDriver. The first test case verifies successful login with valid credentials, while the second test case checks for error handling with invalid credentials. Both tests utilize the Firefox browser and include assertions to compare expected and actual outcomes.

Uploaded by

Mehwish Mehmood
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Lab # 13

Testing Using automation tool selenium web driver

Exercise 1: write a test case for check login with valid credential:.
package tests;

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

public class LoginTests {

@Test

public void TC_1_LoginWithValidCredentials() {

[Link]("[Link]","D:\\Users\\MTaqi\\Downloads\\geckodriver-v0.33.0-
win64-20240209T201254Z-001\\geckodriver-v0.33.0-win64\\[Link]");

WebDriver a=new FirefoxDriver();

//Test Case-01

//step-1. Open browser and navigate to webpage

[Link]("[Link]

//inititate page object for login page

String uname=[Link]();

String pwd=[Link]();
LoginPage loginpage =new LoginPage(a);

//step2. In the Username field ,enter test-data-username(mehwishm)

WebElement usernameField=[Link]([Link]("username"));

[Link]("abidselenium");//web elements function not web browsers

//step 3. In the password field , enter password()

WebElement passField=[Link]([Link]("password"));

//[Link]("TUE06Q");

//step 4. Click login button/press enter key

WebElement Loginbtn=[Link]([Link]("login"));

[Link]();

//test data

[Link](uname);

[Link](pwd);

[Link]();

//expected result vs actual result

String actualPageHeading= [Link]([Link]("login_title")).getText();

String ExpectedPageHeading="Search Hotel (Fields marked with Red asterix (*) are
mandatory)";

[Link](actualPageHeading, ExpectedPageHeading);

//cleanup all data and close browser

[Link]();

}
Output:
Exercise 2: write a test case for check login with Invalid credential:.
@Test

public void TC_2_LoginWithInValidCredentials() {

//WebDriver a=new WebDriver() that is wrong

//WebDriver a=new ChildWebDriver() that is correct

//WebDriver a=new FireFoxDriver() example

[Link]("[Link]","D:\\Users\\Mtaqi\\Downloads\\geckodriver-v0.33.0-
win64-20240209T201254Z-001\\geckodriver-v0.33.0-win64\\[Link]");

WebDriver a=new FirefoxDriver();

//Test Case-01

//step-1. Open browser and navigate to webpage

[Link]("[Link]

//step2. In the Username field ,enter test-data-username(mehwishm)

WebElement usernameField=[Link]([Link]("username"));

[Link]("abidselenium01");//web elements function not web browsers

//step 3. In the password field , enter password()

WebElement passField=[Link]([Link]("password"));
[Link]("TUE06Q02");

//step 4. Click login button/press enter key

WebElement Loginbtn=[Link]([Link]("login"));

[Link]();

//expected result vs actual result

String actualPageHeading= [Link]([Link]("auth_error")).getText();

String ExpectedPageHeading="Invalid Login details or Your Password might have expired. Click
here to reset your password";

[Link](actualPageHeading, ExpectedPageHeading);

//close just focus tab

[Link]();

Output:

You might also like