CCS366 Sta Lab Manual
CCS366 Sta Lab Manual
Student Name:
Year / Semester: III / V
THE KAVERY ENGINEERING COLLEGE Page :
Staff Sign
Awarded
Page No.
Marks
Ex.No. Date Name of the Experiment
THE KAVERY ENGINEERING COLLEGE Page :
EX. NO.:1
AIM
To Develop the test plan for testing an e-commerce application.
DESCRIPTION
Is the website having multiple filters to search products like., price range, category,
brands, etc.?
Are relevant Products displaying after applying single or multiple search filters?
Is there an option to display a fixed number of products on the search page?
Is there any sort option available on the search page and is that working properly?
THE KAVERY ENGINEERING COLLEGE Page :
Is the correct price getting displayed in the shopping cart for the selected product/s?
Is there an option to apply coupon codes?
Can a user increase or decrease the quantity of a product from the shopping cart?
Can a user remove the product from the shopping cart?
THE KAVERY ENGINEERING COLLEGE Page :
RESULT:
Thus the test plan is developed for testing the e-commerce web application.
THE KAVERY ENGINEERING COLLEGE Page :
EX. NO.:2
DESIGN THE TEST CASES FOR TESTING E-COMMERCE APPLICATION
AIM: To Design the test cases for testing the banking application.
DESCRIPTION :
RESULT:
Thus the test cases are developed and tested.
THE KAVERY ENGINEERING COLLEGE Page :
EX.NO.:3
AIM: To Design the test cases for testing the banking application.
DESCRIPTION :
Banking Application:
#include<stdio.h>
#include<conio.h>
unsigned long amount=25000, deposit, withdraw;
int choice, pin, i; char transaction ='y';
void main()
clrscr();
while (pin != 1097)
{
printf("ENTER YOUR PIN NUMBER: ");
scanf("%d", &pin);
if (pin != 1097)
printf("PLEASE ENTER VALID PASSWORD\n");
}
do
{
printf(" Welcome to ATM Service \n"); printf("1. Check Balance\n");
printf("2. Withdraw Cash\n"); printf("3. Deposit Cash\n"); printf("4. Quit\n");
printf("\n\n");
case 2:
printf("\n ENTER THE AMOUNT: ");
scanf("%lu", &withdraw);
if (withdraw % 100 != 0)
{
printf("\n PLEASE ENTER THE AMOUNT IN MULTIPLES OF 100");
}
else if (withdraw >(amount - 1000))
{
printf("\n INSUFFICENT BALANCE");
}
else
{
amount = amount - withdraw;
printf("\n\n PLEASE COLLECT YOUR CASH");
printf("\n YOUR CURRENT BALANCE =RS.%lu", amount);
THE KAVERY ENGINEERING COLLEGE Page :
}
break;
case 3:
printf("\n ENTER THE AMOUNT: ");
scanf("%lu", &deposit); amount = amount + deposit;
printf(" YOUR BALANCE =RS.%lu", amount);
break;
case 4:
printf("\n THANK YOU USING OUR ATM SERVICES");
break; default:
printf("\n INVALID CHOICE");
}
printf("\n\n\n DO U WISH TO HAVE ANOTHER TRANSCATION?(y/n): ");
fflush(stdin);
scanf("%c", &transaction);
if (transaction == 'n'|| transaction == 'N')
i = 1;
} while (!i);
printf("\n\n THANKS FOR USING OUR ATM SERVICE");
getch();
}
output:
4. Quit
Quit.
Features to be tested:
1. Validity of the card.
2. Withdraw Transaction flow of ATM.
3. Authentication of the user’s.
4. Dispense the cash from the account.
5. Verify the balance enquiry.
6. 6. Change of PIN number.
THE KAVERY ENGINEERING COLLEGE Page :
BUG REPORT:
Bug Id: ATM_003
Bug Description: Invalid Account type selected.
Steps to reproduce:
1. Enter a valid user PIN number.
2. Select the withdraw option on the main menu.
3. Choose the correct type of account (either savings or current account).
Expected Result: Enter the Amount screen displayed
Actual Result: Invalid Account type screen is displayed.
Status : Pass/Fail
Bug-Id Bug Name
ATM_001 Invalid Card
ATM_002 Invalid PIN
ATM_003 Invalid Account type
ATM_004 Insufficient Balance
ATM_005 Transaction Limit
ATM_006 Day limit
ATM_007 Invalid money denominations
ATM_008 Receipt not printed
ATM_009 PIN change mismatch
Steps to reproduce:
1. Menu screen should be displayed.
2. Select the withdraw option.
4. Enter sufficient amount to withdraw fromthe account Transaction within the limit.
Expected Result: Cash is dispensed and collect the receipt Actual Result:
Transaction limit exceeded screen is displayed Status : Pass/Fail
5. Amount enter is over the day limit and display screen is displayed.
RESULT:
EX. NO.: 4
AIM:
To develop Test cases for Inventory control system.
DESCRIPTION:
RESULT:
Thus the test case is developed and tested for inventory control system.
THE KAVERY ENGINEERING COLLEGE Page :
AIM
To test client server application and record the results.
DESCRIPTION:
Server
Client
Program:
CHAT SERVER
import java.io.*;
import java.net.*;
class tcpchatserver
{
public static void main(String args[])throws Exception
{
PrintWriter toClient;
BufferedReader fromUser, fromClient;
try
{
ServerSocket Srv = new ServerSocket(5555);
System.out.print("\nServer started\n");
Socket Clt = Srv.accept(); System.out.println("Client connected");
toClient = new PrintWriter(new BufferedWriter(new
OutputStreamWriter(Clt.getOutputStream())), true);
fromClient = new BufferedReader(new InputStreamReader(Clt.getInputStream()));
fromUser = new BufferedReader(new InputStreamReader(System.in));
String CltMsg, SrvMsg;
THE KAVERY ENGINEERING COLLEGE Page :
while(true)
{
CltMsg= fromClient.readLine();
if(CltMsg.equals("end"))
break;
else
{
System.out.println("\nServer <<< " + CltMsg);
System.out.print("Message to Client : ");
SrvMsg = fromUser.readLine();
toClient.println(SrvMsg);
}}
System.out.println("\nClient Disconnected");
fromClient.close();
toClient.close();
fromUser.close();
Clt.close();
Srv.close();
} catch (
Exception E)
{ System.out.println(E.getMessage());
}
}}
Program:
CHAT CLIENT
while (true)
{
System.out.print("\nMessage to Server : ");
CltMsg = fromUser.readLine();
toServer.println(CltMsg);
if (CltMsg.equals("end"))
break;
SrvMsg = fromServer.readLine();
System.out.println("Client <<< " + SrvMsg);
}} catch(Exception E)
{
System.out.println(E.getMessage());
}}}
Output
Server Console
$ javac tcpchatserver.java
$ java tcpchatserver
Server started
Client connected
Server <<< hi
Message to Client : hello
Server <<< how r u?
Message to Client :
fine
Server <<< me too
Message to Client : bye
Client Disconnected
Client Console
$ javac tcpchatclient.java
$ java tcpchatclient
Type "end" to Quit
Message to Server : hi
Client <<< hello
Message to Server : how r
u? Client <<< fine
Message to Server : me too
Client <<< bye
Message to Server : end
RESULT:
Thus the program is executed and testing is performed.
THE KAVERY ENGINEERING COLLEGE Page :
EX. NO:6
PERFORMANCE TESTING OF E-COMMERCE APPLICATION
DESCRIPTION:
In the window that appears, fill the Server Name or IP with the name of the server you want to test. Here,
we have used Simplilearn’s website.
The next step is to add an HTTP Cookie Manager.
THE KAVERY ENGINEERING COLLEGE Page :
Here we shall support cookies by adding HTTP Cookie Manager to the Thread Group:
Right-click on the Thread Group.
Go to Add -> Config Element -> HTTP Cookie Manager
RESULT:
Thus the performance Testing is done using JMeter.
THE KAVERY ENGINEERING COLLEGE Page :
EX. NO:7
AUTOMATION TESTING OF E-COMMERCE APPLICATIONS
DESCRIPTION:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.10.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.3</version>
</dependency>
@BeforeEach
public void setUp() {
System.out.println("*** set up ***");
System.setProperty("webdriver.chrome.driver", "C://development//chromedriver//chromedriver.exe");
webDriver = new ChromeDriver();
}
@AfterEach
public void tearDown() {
System.out.println("*** tear down ***");
webDriver.quit();
}
package selenium;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class SauceTest {
private WebDriver webDriver;
THE KAVERY ENGINEERING COLLEGE Page :
@BeforeEach
public void setUp() {
System.out.println("*** set up ***");
System.setProperty("webdriver.chrome.driver",
"C://development//chromedriver//chromedriver.exe");
webDriver = new ChromeDriver();
}
@Test
public void demoFormTest() {
System.out.println("*** test ***");
webDriver.get("https://saucelabs.com/request-demo");
boolean expectedFieldsExist;
try {
webDriver.findElement(By.id("FirstName"));
webDriver.findElement(By.id("LastName"));
webDriver.findElement(By.id("Company"));
expectedFieldsExist = true;
} catch (NoSuchElementException e) {
expectedFieldsExist = false;
}
assertTrue(expectedFieldsExist);
}
@AfterEach
public void tearDown() {
System.out.println("*** tear down ***");
webDriver.quit();
}
}
THE KAVERY ENGINEERING COLLEGE Page :
Result:
Thus the Automation Testing is performed using Selenium.
THE KAVERY ENGINEERING COLLEGE Page :
EX. NO:8
AUTOMATION TESTING USING TestNG
DESCRIPTION:
From the wizard modal, select the TestNG folder and select the TestNG class as below
THE KAVERY ENGINEERING COLLEGE Page :
Click the ‘New’ button and choose any predefined annotations you wish to have in your class as
below:
Click on finish, and you are ready to start writing your first TestNG class.
THE KAVERY ENGINEERING COLLEGE Page :
Automation Code:
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterClass;
WebDriver driver;
@BeforeClass
public void testSetup()
{
System.setProperty("webdriver.chrome.driver", ".\\Driver\\chromedriver.exe");
driver=new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
@BeforeMethod
public void openBrowser()
{
driver.get("https://www.browserstack.com/");
driver.findElement(By.id("signupModalButton")).click();
System.out.println("We are currently on the following URL" +driver.getCurrentUrl());
}
@AfterMethod
public void postSignUp()
{
System.out.println(driver.getCurrentUrl());
}
THE KAVERY ENGINEERING COLLEGE Page :
@AfterClass
public void afterClass()
{
driver.quit();
}
To execute your report, you can either choose to run directly as a TestNG class or run the XML file created which
contains the class name and details.
To access the TestNG report, you only need to refresh your project folder.
A folder as ‘test output’ will be auto-generated.
RESULT:
Thus the Automation Testing is performed using TestNG.
THE KAVERY ENGINEERING COLLEGE Page :
EX. NO:9
DATA DRIVEN FRAMEWORK ,PAGE OBJECT MODEL using
Selenium and TestNG
AIM: To Perform the Automation testing using Selenium and TestNG.
DESCRIPTION:
Go to the Eclipse IDE and create a project. Add all the dependencies for TestNG, Selenium and
Apache POI.
Create a class file to write the functionality.
Program:
import org.openqa.selenium.By;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
public class ExcelExample{
@Test(dataProvider="testdata")
public void demoClass(String username, String password) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "Path of Chrome Driver");
Webdriver driver = new ChromeDriver();
driver.get("<a href="https://www.browserstack.com/users/sign_in</a>");
driver.findElement(By.name("user[login]")).sendKeys(username);
driver.findElement(By.name("user[password]")).sendKeys(password);
driver.findElement(By.name("commit")).click();
Thread.sleep(5000);
Assert.assertTrue(driver.getTitle().matches("BrowserStack Login | Sign Into The Best Mobile & Browser Testing
Tool"), "Invalid credentials");
System.out.println("Login successful");
}
@AfterMethod
void ProgramTermination() {
driver.quit();
}
@DataProvider(name="testdata")
public Object[][] testDataExample(){
ReadExcelFile configuration = new ReadExcelFile("Path_of_Your_Excel_File");
int rows = configuration.getRowCount(0);
Object[][]signin_credentials = new Object[rows][2];
for(int i=0;i<rows;i++)
{
signin_credentials[i][0] = config.getData(0, i, 0);
signin_credentials[i][1] = config.getData(0, i, 1);
}
return signin_credentials;
}
}
THE KAVERY ENGINEERING COLLEGE Page :
import java.io.File;
import java.io.FileInputStream;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ReadExcelFile{
XSSFWorkbook work_book;
XSSFSheet sheet;
public ReadExcelFile(String excelfilePath) {
try {
File s = new File(excelfilePath);
FileInputStream stream = new FileInputStream(s);
work_book = new XSSFWorkbook(stream);
}
catch(Exception e) {
System.out.println(e.getMessage());
}
}
public String getData(int sheetnumber, int row, int column){
sheet = work_book.getSheetAt(sheetnumber);
String data = sheet.getRow(row).getCell(column).getStringCellValue();
return data;
}
public int getRowCount(int sheetIndex){
int row = work_book.getSheetAt(sheetIndex).getLastRowNum();
row = row + 1;
return row;
}
package com.ontestautomation.seleniumtestngpom.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
this.driver = driver;
driver.findElement(By.name("username")).sendKeys(username);
driver.findElement(By.name("password")).sendKeys(password);
driver.findElement(By.xpath("//input[@value='Log In']")).click();
return new ErrorPage(driver);
}
driver.findElement(By.name("username")).sendKeys(username);
driver.findElement(By.name("password")).sendKeys(password);
driver.findElement(By.xpath("//input[@value='Log In']")).click();
return new HomePage(driver);
}
}
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
this.driver = driver;
}
return driver.findElement(By.className("error")).getText();
}
}
package com.ontestautomation.seleniumtestngpom.tests;
WebDriver driver;
@BeforeSuite
public void setUp() {
@Parameters({"username","incorrectpassword"})
@Test(description="Performs an unsuccessful login and checks the resulting error message")
public void testLoginNOK(String username, String incorrectpassword) {
@AfterSuite
public void tearDown() {
driver.quit();
}
}
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cucumber.version>7.6.0</cucumber.version>
<selenium.version>4.3.0</selenium.version>
<webdrivermanager.version>5.2.1</webdrivermanager.version>
<testng.version>7.4.0</testng.version>
<apache.common.version>2.4</apache.common.version>
<maven.compiler.plugin.version>3.10.1</maven.compiler.plugin.version>
<maven.surefire.plugin.version>3.0.0-M7</maven.surefire.plugin.version>
<maven.compiler.source.version>11</maven.compiler.source.version>
<maven.compiler.target.version>11</maven.compiler.target.version>
</properties>
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
</dependency>
THE KAVERY ENGINEERING COLLEGE Page :
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>${maven.compiler.source.version}</source>
<target>${maven.compiler.target.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
THE KAVERY ENGINEERING COLLEGE Page :
<version>${maven.surefire.plugin.version}</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cucumber.version>7.6.0</cucumber.version>
<selenium.version>4.3.0</selenium.version>
<webdrivermanager.version>5.2.1</webdrivermanager.version>
<testng.version>7.4.0</testng.version>
<apache.common.version>2.4</apache.common.version>
<maven.compiler.plugin.version>3.10.1</maven.compiler.plugin.version>
<maven.surefire.plugin.version>3.0.0-M7</maven.surefire.plugin.version>
<maven.compiler.source.version>11</maven.compiler.source.version>
<maven.compiler.target.version>11</maven.compiler.target.version>
</properties>
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>${maven.compiler.source.version}</source>
<target>${maven.compiler.target.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
THE KAVERY ENGINEERING COLLEGE Page :
import java.time.Duration;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import io.cucumber.java.After;
import io.cucumber.java.Before;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import io.github.bonigarcia.wdm.WebDriverManager;
@Before
public void setUp() {
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(TIMEOUT));
driver.manage().window().maximize();
}
driver.get(url);
// login to application
driver.findElement(By.name("username")).sendKeys(userName);
driver.findElement(By.name("password")).sendKeys(passWord);
driver.findElement(By.xpath("//*[@id='app']/div[1]/div/div[1]/div/div[2]/div[2]/form/div[3]/button")).submit();
@After
public void teardown() {
driver.quit();
}
import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;
emailable-report.html
Index.html
RESULT:
Thus the Automation testing is performed using Selenium and TestNG.