0% found this document useful (0 votes)
71 views

Department of ISE,: I) Ii) Iii) Iv) V) I)

This document contains sample code for testing different programming constructs like loops, conditional statements, and functions using JUnit tests in Java. It includes: 1. Code to test squaring a number and counting occurrences of a character in a string. 2. Test cases to validate squaring a number using JUnit assertions and to count the occurrences of 'a' in a given string. 3. The document discusses writing test cases for different scenarios like valid, invalid and edge cases and running the JUnit tests.

Uploaded by

BM Mithun
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)
71 views

Department of ISE,: I) Ii) Iii) Iv) V) I)

This document contains sample code for testing different programming constructs like loops, conditional statements, and functions using JUnit tests in Java. It includes: 1. Code to test squaring a number and counting occurrences of a character in a string. 2. Test cases to validate squaring a number using JUnit assertions and to count the occurrences of 'a' in a given string. 3. The document discusses writing test cases for different scenarios like valid, invalid and edge cases and running the JUnit tests.

Uploaded by

BM Mithun
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/ 56

BMS COLLEGE OF ENGINEERING BANGALORE-19

(Autonomous Institute, Affiliated to VTU)


Department of ISE,

Software Testing

Course Code: 20IS6PCSTG Course Title: Software Testing

Semester: VI BM MITHUN 6th B

1.using manual testing write a test case to check the Facebook login.

2. Write a c program to demonstrate the working of the following constructs with


different range of values and test cases such as
Test case No 1: Positive values within range
Test case No 2: Negative values within a range
Test Case No 3: Out of range values testing
i) Do…while
ii) While…do
iii) if …else
iv) Switch
v) For Loops in C language

i) Do ... while
#include <stdio.h>
#include <stdlib.h>
void main()
{
//Range is taken as -10 to 10
int low=-10;
int high=10;
int i=-15;
do
{
if(i>=low && i<=high)
{
if(i<0)
printf("%d is a negative number ...\n",i);
else if(i>0)
printf("%d is a positive number ...\n",i);
}
else
printf("%d is out of range ...\n",i);
i+=1;
}while(i<=15);
}
Output:

-15 is out of range ...


-14 is out of range ...
-13 is out of range ...
-12 is out of range ...
-11 is out of range ...
-10 is a negative number ...
-9 is a negative number ...
-8 is a negative number ...
-7 is a negative number ...
-6 is a negative number ...
-5 is a negative number
... -4 is a negative
number ... -3 is a
negative number ... -2 is
a negative number ... -1
is a negative number ... 1
is a positive number ...
2 is a positive number ...
3 is a positive number ...
4 is a positive number ...
5 is a positive number ...
6 is a positive number ...
7 is a positive number ...
8 is a positive number ...
9 is a positive number ...
10 is a positive number
... 11 is out of range ...
12 is out of range ...
13 is out of range ...
14 is out of range ...
15 is out of range ...
ii) While ... do

#include <stdio.h>
#include <stdlib.h>
void main()
{
//Range is taken as -10 to 10
int low=-10;
int high=10;
int i=-15;
while(i<=15)
{
if(i>=low && i<=high)
{
if(i<0)
printf("%d is a negative number ...\n",i);
else
printf("%d is a positive number ...\n",i);
}
else
printf("%d is out of range ...\n",i);
i+=1;
}
}
Output:

-15 is out of range ... -14 is


out of range ... -13 is out
of range ... -12 is out of
range ... -11 is out of range
... -10 is a negative
number ...
-9 is a negative number
... -8 is a negative
number ... -7 is a
negative number ... -6 is
a negative number ... -5
is a negative number ...
-4 is a negative number
... -3 is a negative
number ... -2 is a
negative number ... -1 is
a negative number ... 0 is
a positive number ...
1 is a positive number ...
2 is a positive number ...
4 is a positive number ...
5 is a positive number ...
6 is a positive number ...
7 is a positive number ...
8 is a positive number ...
9 is a positive number ...
10 is a positive number ...
11 is out of range ...
12 is out of range ...
13 is out of range ...
14 is out of range ...
15 is out of range ...
iii) if ... else

#include <stdio.h>
#include <stdlib.h>
void main()
{
//Range is taken as -10 to 10
int low=-10;
int high=10;
int i=-15;
while(i<=15)
{
if(i>=low && i<=high)
{
if(i<0)
printf("%d is a negative number ...\n",i);
else
printf("%d is a positive number ...\n",i);
}
else
printf("%d is out of range ...\n",i);
i+=1;
}
}

Output:

-15 is out of range ...


-14 is out of range ...
-13 is out of range ...
-12 is out of range ...
-11 is out of range ...
-10 is a negative number
... -9 is a negative number
... -8 is a negative number
... -7 is a negative number
... -6 is a negative number
... -5 is a negative number
... -4 is a negative number
... -3 is a negative number
... -2 is a negative number
... -1 is a negative number
... 0 is a positive number ...
1 is a positive number ...
2 is a positive number ...
3 is a positive number ...
4 is a positive number ...
5 is a positive number ...
6 is a positive number ...
7 is a positive number ...
8 is a positive number ...
9 is a positive number ...
10 is a positive number
... 11 is out of range ...
12 is out of range ...
13 is out of range ...
14 is out of range ...
15 is out of range ...

iv) switch case

#include <stdio.h>
#include <stdlib.h>
void main()
{
//Range is taken as -10 to 10
int low=-10;
int high=10;
int i=-15;
while(i<=15)
{
int value1,value2;
if(i>=low && i<=high)
value1=1;
else
value1=0;
switch(value1)
{
case 1:
if(i<0)
value2=1;
else
value2=0;
switch(value2)
{
case 1:
printf("%d is a negative number ...\n",i);
break;
case 0:
printf("%d is a positive number ...\n",i);
break;
}
break;
case 0:
printf("%d is Out of Range ... \n",i);
break;
}
i+=1;
}
}

Output:
-15 is Out of Range ...
-14 is Out of Range ...
-13 is Out of Range ...
-12 is Out of Range ...
-11 is Out of Range ...
-10 is a negative number
... -9 is a negative number
... -8 is a negative number
... -7 is a negative number
... -6 is a negative number
... -5 is a negative number
... -4 is a negative number
... -3 is a negative number
... -2 is a negative number
... -1 is a negative number
...
0 is a positive number ...
1 is a positive number ...
2 is a positive number ...
3 is a positive number ...
4 is a positive number ...
5 is a positive number ...
6 is a positive number ...
7 is a positive number ...
8 is a positive number ...
9 is a positive number ...
10 is a positive number
...
11 is Out of Range ...
12 is Out of Range ...
13 is Out of Range ...
14 is Out of Range ...
v)For Loop

#include <stdio.h>
#include <stdlib.h>
void main()
{
//Range is taken as -10 to 10
int low=-10;
int high=10;
int i;
for(i=-15;i<=15;i++)
{
if(i>=low && i<=high)
{
if(i<0)
printf("%d is a negative number ...\n",i);
else
printf("%d is a positive number ...\n",i);
}
else
printf("%d is Out of Range ...\n",i);
}
}

Output:

-15 is Out of Range ...


-14 is Out of Range ...
-13 is Out of Range ...
-12 is Out of Range ...
-11 is Out of Range ...
-10 is a negative number
... -9 is a negative number
...
-8 is a negative number
... -7 is a negative
number ... -6 is a
negative number ... -5 is
a negative number ... -4
is a negative number ...
-3 is a negative number
... -2 is a negative
number ... -1 is a
negative number ... 0 is a
positive number ...
1 is a positive number ...
2 is a positive number ...
3 is a positive number ...
4 is a positive number ...
5 is a positive number ...
6 is a positive number ...
7 is a positive number ...
8 is a positive number ...
9 is a positive number ...
10 is a positive number ...
11 is Out of Range
... 12 is Out of
Range ... 13 is Out
of Range ... 14 is
Out of Range ... 15
is Out of Range ...
3. Write a program in c language for matrix multiplication failure ―Introspect the
causes for its failure and write down the possible reasons for its failure.
Test Cases includes
Test case no: 1Test case name: Equal no.of rows &amp; cols
Test case no: 2 Test case name: Cols of 1st matrix not equal to rows of 2nd matrix Test case
no: 3Test case name: Out of range values testing
Matrix multiplication:
#include<stdio.h>
#include<stdlib.h> #include<iostream> int main(){
int a[10][10],b[10][10],mul[10][10],r,c,i,j,k; system("cls");
printf("enter the number of row="); scanf("%d",&r);
printf("enter the number of column="); scanf("%d",&c);
printf("enter the first matrix element=\n"); for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
scanf("%d",&a[i][j]);
}}
printf("enter the second matrix element=\n"); for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
scanf("%d",&b[i][j]);
}
}
printf("multiply of the matrix=\n"); for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{ mul[i][j]=0; for(k=0;k<c;k++)
{
mul[i][j]+=a[i][k]*b[k][j];
}
}}
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf("%d\t",mul[i][j]);
}
printf("\n");
} return 0; }
Output:

Test case no: 1 Test case name: Equal no.of rows & cols
Enter the Dimension of First Matrix : 2 2
Enter the Dimension of Second Matrix : 2 2
Enter the Elements of the First Matrix :
1
2
3
4
Enter the Elements of the Second Matrix :
4
5
6
7
Resultant Matrix :
16 19
36 43

Test case no: 2 Test case name: Cols of 1st matrix not equal to rows of 2nd
matrix
Enter the Dimension of First Matrix : 2 2
Enter the Dimension of Second Matrix : 3 3
Cannot Perform Matrix Multiplication

Test case no: 3 Test case name: Out of range values testing
Enter the Dimension of First Matrix : 11 11
Enter the Dimension of Second Matrix : 11 3
Values Our of Range
4. Unit test the given programs and write the test cases for (i) squaring a number (ii)
finding a count of a character 'a' or "A' in a word using JUnit.
Step 1. Create a new java project, SeleniumJavaAutomation and
package, Testing/SeleniumFirstClass.

Step 2 - Type the code for squaring and finding ‘A’ in a given string and save.

package SeleniumFirstClass;
import org.junit.Test;
public class MyJunitTest {
@Test
public int square(int x)
{
return x*x;
}
public int countA(String word) {
int count=0;
for(int i=0; i<word.length(); i++) { if(word.charAt(i)=='a'|| word.charAt(i)=='A')
{ count++;
}
}
return count++;}}
Click on Testing��New→ JUnit Test Case→ Name: squareTest→ Finish→ OK
3. Write the code to test the square of a number function in squareTest.java file package
SeleniumFirstClass;
import static org.junit.Assert.*;
import org.junit.Test;
public class squareTest {
@Test
public void test() {
MyJunitTest test = new MyJunitTest();int output = test.square(5);assertEquals(25,output);
}
}

4. Run the test case as Junit Test case

5. Now let’s write a Test case to check the next code(counting the occurrence of a
character’a’ in a word):

package SeleniumFirstClass;
import static org.junit.Assert.*;
import org.junit.Test;

@Test
public void test() {
MyJunitTest test= new MyJunitTest();
int output = test.countA("alphabet");
assertEquals(2, output);
}
}

6. Run as Junit Test

7. If we want to run all the test cases one after another in a single file. Go to Package
Explorer→ JUnitTest→ New→ Other→ [In selecta wizard]: Click Java→ JUnit→ JUnit
Test Suite→ Package: Testing→ finish
5. Boundary value testing- Triangle problem
Boundary value analysis program
Design and develop a program in a language of your choice to solve the triangle problem
defined as follows: Accept three integers which are supposed to be the three sides of triangle
and determine if the three values represent an equilateral triangle, isosceles triangle, scalene
triangle, or they do not form a triangle at all. Derive test cases for your program based on
boundary value analysis, execute the test cases and discuss the results

#include<stdio.h>
int main()
{
int a,b,c,c1,c2,c3;
char istriangle;
do {
printf("\nenter 3 integers which are sides of triangle\n");
scanf("%d%d%d",&a,&b,&c);
printf("\na=%d\tb=%d\tc=%d",a,b,c);
c1 = a>=1 && a<=10;
c2= b>=1 && b<=10;
c3= c>=1 && c<=10;
if (!c1)
printf("\n the value of a=%d is not the range of permitted value", a);
if (!c2)
printf("\nthe value of b=%d is not the range of permitted value", b);
if (!c3)
printf("\nthe value of c=%d is not the range of permitted value", c);
} while (! (c1 && c2 && c3));

// to check is it a triangle or not


if( a<b+c && b<a+c && c<a+b )
istriangle='y';
else
istriangle ='n';
if (istriangle=='y')
if ((a==b) && (b==c))
printf("equilateral triangle\n");
else if ((a!=b) && (a!=c) && (b!=c))
printf("scalene triangle\n");
else
printf("isosceles triangle\n");
else
printf("Not a triangle\n");
return 0
}
Test Case Name: Boundary Value Analysis for 1 Enter the min value for 1 1
triangle problem
a, b and c
Test Data: Enter the 3 Integer Value (a, b and c)
Pre-condition: 1 ≤ a ≤ 10, 1 ≤ b ≤ 10 and 1 ≤ c ≤ 10
and a < b + c, b < a + c and c < a + b Brief
Description: Check whether given value for a 2 Enter min value for 2 1 1
equilateral, isosceles, Scalene triangle or can't from a items and min+1 for any
triangle one item

Triangle Problem -Boundary value Test cases for 3 Enter min value for 2 1 2
input data: items and min+1 for any
Cas Description Input d one item
e
a b 4 Enter min value for 2 2 1
id
items and min+1 for any
one item
5 Enter normal value 5 5
for 2 items and 1 item
is min value
pass
6 Enter normal value 5 1
for 2 items and 1 item
is min value
pass
7 Enter normal value 1 5
for 2 items and 1 item
is min value
pass
8 Enter the normal value 5 5
for a, b, and c
pass
9 Enter the normal value 5 5
for 2 items and 1 item
is max value pass

Comments pass pass

pass

pass
pass
10 Enter the normal value 5 10 5 Not a triangle Not a
for 2 items and 1 item triangle
is max value

11 Enter the normal value 10 5 5 Not a triangle Not a


for 2 items and 1 item triangle
is max value

12 Enter the max value 10 10 9 Isosceles Isosceles


for 2 items and max-1 triangle triangle
for any one item

13 Enter the max value 10 9 10 Isosceles Isosceles


for 2 items and max-1 triangle triangle
for any one item

14 Enter the max value 9 10 10 Isosceles Isosceles


for 2 items and max-1 triangle triangle
for any one item

15 Enter max value for 10 10 10 Equilateral Equilate


a, b and c triangle ra l
triangle

pass
pass

pass

pass

pass

6. Commission- Boundary Value Testing


Design, develop, code and run the program in any suitable language to solve the commission
problem. Analyse it from the perspective of boundary value testing, derive different test
cases, execute these test cases and discuss the test results The Commission Problem A rifle
salesperson in the former Arizona Territory sold rifle locks, stocks, and barrels made by a
gunsmith in Missouri. Locks cost $45, stocks cost $30, and barrels cost $25. The salesperson
had to sell at least one lock, one stock, and one barrel (but not necessarily one complete rifle)
per month, and production limits were such that the most the salesperson could sell in a
month was 70 locks, 80 stocks, and 90 barrels. After each town visit, the salesperson sent a
telegram to the Missouri gunsmith with the number of locks, stocks, and barrels sold in that
town. At the end of a month, the salesperson sent a very short telegram showing –1 lock sold.
The gunsmith then knew the sales for the month were complete and computed the
salesperson’s commission as follows: 10% on sales up to (and including) $1000, 15% on the
next $800, and 20% on any sales in excess of $1800. Test Cases for the Commission Problem
Instead of going through 125 test cases again, we will look at some more interesting test cases
for the commission problem. This time, we will look at boundary values derived from the
output range, especially near the threshold points of $1000 and $1800 where the commission
percentage changes.
Test data : price Rs for lock - 45.0 , stock - 30.0 and barrel - 25.0
sales = total lock * lock price + total stock * stock price + total barrel * barrel price
commission : 10% up to sales Rs 1000 , 15 % of the next Rs 800 and 20 % on any
sales in excess of 1800
Pre-condition : lock = -1 to exit and 1< =lock < = 70 , 1<=stock <=80 and
1<=barrel<=90

Code snippet:

Checking boundary value for locks, stocks and barrels and commission
Input data Expected Actual output
output

Ca Descrip Tota Tota Tota Sal Comm Sal Comm Stat Com
se tio n l l l es iss ion es iss ion us me nt
id Loc stoc barre
ks ks ls

1 Enter 1 1 1 100 10 100 10 Pass Output


the min minim
value um
for
locks,
stocks
and
barrels

2 Enter the 1 1 2 125 12.5 125 12.5 Pass Output


min value minim
for 2 um+
items
3 and min 1 2 1 130 13 130 13 Pass Output
+1 for minim
any one um+
item
4 2 1 1 145 14.5 145 14.5 Pass Output
minim
um +

5 Enter the 5 5 5 500 50 500 50 Pass Midpoi


value nt
sales
approxi
ma tely
mid
value
between
100 to
1000

6 Enter the 10 10 9 975 97.5 975 97.5 Pass Border


values to point-
calculate
7 the 10 9 10 970 97.5 970 97.0 Fail Border
commis point-
sio n for
8 9 10 10 955 95.5 955 95.5 Pass Border
sales
point-
nearly
less
than
1000

9 Enter 10 10 10 100 100 100 100 Pass Border


the 0 0 point
values
sales
exactly
equal to
1000

10 Enter the 10 10 11 102 103.75 102 103.75 Pass Border


values to 5 5 point+
calculate
11 the 10 11 10 103 104.5 103 104.5 Pass Border
commis 0 0 point+
sio n for
12 11 10 10 104 106.75 104 106.75 Pass Border
sales
5 5 point+
nearly
greater
than
1000

13 Enter 14 14 14 140 160 140 160 Pass Midpoi


the 0 0 nt
value
sales
approxi
ma tely
mid
value
between
1000 to
1800

14 Enter the 18 18 17 177 216.25 177 216.25 Pass Border


values to 5 5 point-
calculate
15 the 18 17 18 177 215.5 177 215.5 Pass Border
commis 0 0 point-
sio n for
16 17 18 18 175 213.25 175 213.25 Pass Border
sales
5 5 point-
nearly
less
than
1800

17 Enter 18 18 18 180 220 180 220 Pass Border


the 0 0 point
values
sales
exactly
equal to
1800

18 Enter the 18 18 19 182 225 182 225 Pass Border


values to 5 5 point+
calculate
19 the 18 19 18 184 229 183 226 Fail Border
commis 5 0 point+
sio n for
20 19 18 18 184 229 184 229 Pass Border
sales
5 5 point+
nearly
greater
than
1800

21 Enter the 48 48 48 480 820 480 820 Pass Midpoi


values 0 0 nt
normal
value for
lock,
stock
and
barrel

22 Enter the 70 80 89 777 1415 777 1415 Pass Output


max 5 5 maxim
value um -
for 2
23 items 70 79 90 777 1414 777 1414 Pass Output
and max 0 0 maxim
- um -
1 for
24 any one 69 80 90 775 1411 775 1411 Pass Output
item 5 5 maxim
um -

25 Enter 70 80 90 780 1420 780 1420 Pass Output


the max 0 0 maxim
value um
for
locks,
stocks
and
barrels

Output Special Value Test Cases


Input data Expected output Actual output

Cas Descri Tota Tota Total Sal Comm Sal Comm Stat Comm
e id pti on l l barre es iss ion es iss ion us ent
Loc stoc ls
ks ks

1 Enter 11 10 8 995 99.5 955 99.5 Pass Border


the point -
rando
m
values
such
that to
calculate
commi
ss ion
for
sales
nearly
less than
1000

2 Enter 10 11 9 100 100.75 100 100.75 Pass Border


the 5 5 point +
rando
m
values
such
that to
calculate
commi
ss ion
for
sales
nearly
greater
than
1000
3 Enter 18 17 19 179 219.25 179 219.25 Pass Border
the 5 5 point -
rando
m
values
such
that to
calculate
commi
ss ion
for
sales
nearly
less than
1800

4 Enter 18 19 17 180 221 180 221 Pass Border


the 5 5 point +
rando
m
values
such
that to
calculate
commi
ss ion
for
sales
nearly
greater
than
1800

CODE:
#include<stdio.h>
int main()
{
int locks, stocks, barrels, tlocks, tstocks, tbarrels;
float lprice, sprice, bprice, sales, comm;
int c1,c2,c3,temp;
lprice=45.0;
sprice=30.0;
bprice=25.0;
tlocks=0;
tstocks=0;
tbarrels=0;
printf("\nenter the number of locks and to exit the loop enter -1 for locks\n");
scanf("%d",&locks);
while(locks!=-1)
{
c1=(locks<=0||locks>70);
printf("enter the number of stocks and barrels\n");
scanf("%d%d",&stocks,&barrels);
c2=(stocks<=0||stocks>80);
c3=(barrels<=0||barrels>90);
if(c1)
printf("value of locks not in the range 1..70 ");
else
{
temp=tlocks+locks;
if(temp>70)
printf("new total locks =%d not in the range 1..70 so old
",temp); else
tlocks=temp;
}
printf("total locks = %d\n",tlocks);
if(c2)
printf("value of stocks not in the range 1..80 ");
else
{
temp=tstocks+stocks;
if(temp>80)
printf("new total stocks =%d not in the range 1..80 so old ",temp);
else
tstocks=temp;
}
printf("total stocks=%d\n",tstocks);
if(c3)
printf("value of barrels not in the range 1..90 ");
else
{
temp=tbarrels+barrels;
if(temp>90)
printf("new total barrels =%d not in the range 1..90 so old ",temp);
else
tbarrels=temp;
}
printf("total barrel=%d",tbarrels);
printf("\nenter the number of locks and to exit the loop enter -1 for locks\n");
scanf("%d",&locks);
}
printf("\ntotal locks = %d\ntotal stocks =%d\ntotal barrels =%d\n",tlocks,tstocks,tbarrels);
sales = lprice*tlocks+sprice*tstocks+bprice*tbarrels;
printf("\nthe total sales=%f\n",sales);
if(tlocks>0&&tstocks>0&&tbarrels>0)
{
if(sales > 1800.0)
{
comm=0.10*1000.0;
comm=comm+0.15*800;
comm=comm+0.20*(sales-1800.0);
}
else if(sales > 1000)
{
comm =0.10*1000;
comm=comm+0.15*(sales-1000);
}
else
comm=0.10*sales;
printf("the commission is=%f\n",comm);
}
else
printf(" Commission cannot be calculated \n");
return 0;
}
7. Equivalence class – Triangle Problem
Design and develop a program in a language of your choice to solve the triangle problem
defined as follows: Accept three integers which are supposed to be the three sides of a
triangle and determine if the three values represent an equilateral triangle, isosceles triangle,
scalene triangle, or they do not form a triangle at all. Assume the upper limit for the size of
any side is 10. Derive test cases for your program based on equivalence class partitioning,
execute the test cases and discuss the results.

Test Data : Enter the 3 Integer Value( a , b And c )


Pre-condition : 1 ≤ a ≤ 10 , 1 ≤ b ≤ 10 and 1 ≤ c ≤ 10 and a < b + c , b < a + c and c < a + b
Brief Description : Check whether given value for a equilateral, isosceles , Scalene triangle or
Not a triangle

Code snippet:

do
{
printf("\nenter 3 integers which are sides of triangle\n");
scanf("%d%d%d",&a,&b,&c);
printf("\na=%d\tb=%d\tc=%d",a,b,c);
c1 = a>=1 && a<=10;
c2= b>=1 && b<=10;
c3= c>=1 && c<=10;
if (!c1)
printf("\n the value of a=%d is not the range of permitted value",a);
if (!c2)
printf("\n the value of b=%d is not the range of permitted value",b);
if (!c3)
printf("\n the value of c=%d is not the range of permitted value",c);
} while(!(c1 && c2 && c3));
// to check is it a triangle or not
if( a<b+c && b<a+c && c<a+b )
istriangle='y';
else
istriangle ='n';
if (istriangle=='y')
if ((a==b) && (b==c))
printf("equilateral triangle\n");
else if ((a!=b) && (a!=c) && (b!=c))
printf("scalene triangle\n");
else
printf("isosceles triangle\n");
else
printf("Not a triangle\n");
Triangle Problem -Equivalence Class Test cases for input data
Weak Normal Equivalence Class Testing
Case Description Input data Expected output Actual output Comm
id en ts
a b c

1 Enter value for a 5 5 5 Equilateral triangle Equilateral Pass


, b and c triangle

2 Enter value for a 2 2 3 Isosceles triangle Isosceles Pass


, b and c triangle

3 Enter value for a 3 4 5 Scalene triangle Scalene Pass


, b and c triangle

4 Enter value for a 4 1 2 Not a triangle Not a triangle Pass


, b and c

Weak Robust Equivalence Class Testing

5 Enter one invalid -1 5 5 Value of a is not Value of a pass


input and two in the range of is not in
valid value for a, permitted values the
b and c range of
permitted
values

6 Enter one invalid 5 -1 5 Value of b is not Value of b pass


input and two in the range of is not in
valid value for a, permitted values the
b and c range of
permitted
values

7 Enter one invalid 5 5 -1 Value of c is not Value of c Pass


input and two in the range of is not in
valid value for a, permitted values the
b and c range of
permitted
values

8 Enter one invalid 11 5 5 Value of a is not Value of a Pass


input and two in the range of is not in
valid value for a, permitted values the
b and c range of
permitted
values

9 Enter one invalid 5 11 5 Value of b is not Value of b pass


input and two in the range of is not in
valid value for a, permitted values the
b and c range of
permitted
values
10 Enter one invalid 5 5 11 Value of c is not Value of c pass
input and two in the range of is not in
valid value for a, permitted values the
b and c range of
permitted
values

Strong Robust Equivalence Class Testing

11 Enter one invalid -1 5 5 Value of a is not Value of a pass


input and two in the range of is not in
valid value for a permitted values the
, b and c range of
permitted
values

12 Enter one invalid 5 -1 5 Value of b is not Value of b Pass


input and two in the range of is not in
valid value for a permitted values the
, b and c range of
permitted
values

13 Enter one invalid 5 5 -1 Value of c is not Value of c Pass


input and two in the range of is not in
valid value for a permitted values the
, b and c range of
permitted
values

14 Enter two invalid -1 -1 5 Value of a,b is Value of a,b Pass


input and one not in the range is not in the
valid value for a of range of
, b and c permitted values permitted
values

15 Enter two invalid 5 -1 -1 Value of b,c is Value of b,c Pass


input and one not in the range is not in the
valid value for a of range of
, b and c permitted values permitted
values

16 Enter two invalid -1 5 -1 Value of a,c is Value of a,c Pass


input and one not in the range is not in the
valid value for a of range of
, b and c permitted values permitted
values

17 Enter all invalid -1 -1 -1 Value of a,b,c is Value of Pass


inputs not in the range a,b,c is not
of permitted in the
values range of
permitted
values
Equivalence classes:
D1 = {<a, b, c>: a = b = c}
D2 = {<a, b, c>: a = b, a ≠ c}
D3 = {<a, b, c>: a = c, a ≠ b}
D4 = {<a, b, c>: b = c, a ≠ b}
D5 = {<a, b, c>: a ≠ b, a ≠ c, b ≠ c}
D6 = {<a, b, c>: a ≥ b + c}
D7 = {<a, b, c>: b ≥ a + c}
D8 = {<a, b, c>: c ≥ a + b}

Code:
#include<stdio.h>
int main()
{
int a,b,c,c1,c2,c3;
char istriangle;
do
{
printf("\nenter 3 integers which are sides of triangle\n");
scanf("%d%d%d",&a,&b,&c);
printf("\na=%d\tb=%d\tc=%d",a,b,c);
c1 = a>=1 && a<=10;
c2= b>=1 && b<=10;
c3= c>=1 && c<=10;
if (!c1)
printf("\nthe value of a=%d is not the range of permitted
value",a); if (!c2)
printf("\nthe value of b=%d is not the range of permitted
value",b); if (!c3)
printf("\nthe value of c=%d is not the range of permitted
value",c); } while(!(c1 && c2 && c3));
// To check is it a triangle or not
if( a<b+c && b<a+c && c<a+b )
istriangle='y';
else
istriangle ='n';
// To check which type of triangle
if (istriangle=='y')
if ((a==b) && (b==c))
printf("equilateral triangle\n");
else if ((a!=b) && (a!=c) && (b!=c))
printf("scalene triangle\n");
else
printf("isosceles triangle\n");
else
printf("Not a triangle\n");
return 0;
}

Output:
8. Equivalence- Next Date
Design, develop, code and run the program in any suitable language to implement the Next
Date function. Analyse it from the perspective of equivalence class value testing, derive
different test cases, execute these test cases and discuss the test results.

Code snippets:

if(day<1 || day>31)
{
printf("value of day, not in the range 1...31\n");
flag='n';
}
if(month<1 || month>12)
{
printf("value of month, not in the range 1....12\n");
flag='n';
}
else if(check(day,month))
{
printf("value of day, not in the range day<=30");
flag='n';
}
………….
if(year<=1812 || year>2013)
{
printf("value of year, not in the range 1812...... 2013\n");
flag='n';
}
if(month==2)
{
if(isleap(year) && day>29)
{
printf("invalid date input for leap year");
flag='n';
}
else if(!(isleap(year))&& day>28)
{
printf("invalid date input for not a leap year");
flag='n';
}
}
………..
switch (month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:if(day<31)
tomm_day=day+1;
else
{
tomm_day=1;
tomm_month=month+1;
}
break;
case 4:
case 6:
case 9:
case 11: if(day<30)
tomm_day=day+1;
else
{
tomm_day=1;
tomm_month=month+1;
}
break;
case 12: if(day<31)
tomm_day=day+1;
else
{
tomm_day=1;
tomm_month=1;
if(year==2013)
{
printf("the next day is out of boundary value of year\n");
tomm_year=year+1;
}
else
tomm_year=year+1;
}
break;
case 2:
if(day<28)
tomm_day=day+1;
else if(isleap(year)&& day==28)
tomm_day=day+1;
else if(day==28 || day==29)
{
tomm_day=1;
tomm_month=3;
}
break;
}
// print the next date values as day, month, year format
Valid equivalence classes are:

M1 = {month: 1 ≤ month ≤ 12}


D1 = {day: 1 ≤ day ≤ 31}
Y1 = {year: 1812 ≤ year ≤ 2012}

Invalid equivalence classes are:

M2 = {month: month < 1}


M3 = {month: month > 12}
D2 = {day: day < 1}
D3 = {day: day > 31}
Y2 = {year: year < 1812}
Y3 = {year: year > 2012}

Next date Output Equivalence Class Testing

Weak and Strong Normal Equivalence Class test case


Input data Expected output Actual output

Case Descripti Month Day Year Month Day Year Month Day Year Comment
id o
n

1 Enter the 6 15 1912 6 16 1912 6 16 1912 pass


M1, D1
and Y1
valid
cases

Cas Descrip Mont Da Yea Mont Da Yea Mont Da Yea Comme


e id tio n h y r h y r h y r nt

1 Enter the 6 15 191 6 16 191 6 16 191 pass


M1, D1 2 2 2
and Y1
cases

pass
2 Enter the -1 15 Value of month not in the range
M2 , D1 1 ... 12
and Y1
cases
3 Enter the 13 15 1912 Value of month Value of pass
M3 ,D1 not in the range month not in
and Y1 1 ... 12 the range
cases
1 ... 12

4 Enter the 6 -1 1912 Value of day not Value of day pass


M1, D2 in the range 1 ... not in the
and Y1 31 range 1 ... 31
cases

5 Enter the 6 32 1912 Value of day not Value of day pass


M1, D3 in the range 1 ... not in the
and Y1 31 range 1 ... 31
cases

6 Enter the 6 15 1811 Value of year not Value of year pass


M1, D1 in the range 1812 not in the
and Y2 ... range 1812 ...
cases 2012 2012

7 Enter the 6 15 2013 Value of year not Value of year pass


M1, D1 in the range 1812 not in the
and Y3 ... range 1812 ...
cases 2012 2012

Strong Robust test cases


Input data Expected output Actual output

Case Descripti Month Day Year Month Day Year Month Da Year Comment
id o y
n

1 Enter the -1 15 1912 Value of month Value of month pass


M2 , D1 not in the range not in the range
and Y1 1 ... 12 1 ... 12
cases

2 Enter the 6 -1 1912 Value of day not Value of day not pass
M1, D2 in the range 1 ... in the range 1 ...
and Y1 31 31
cases

3 Enter the 6 15 1811 Value of year not Value of year not pass
M1, D1 in the range in the range
and Y2 1812 ... 1812 ...
cases 2012 2012
4 Enter the -1 -1 1912 Value of month Value of month pass
M2 , D2 not in the range not in the range
and Y1 1 ... 12 1 ... 12
cases
Value of day not Value of day not
in the range 1 ... in the range 1 ...
31 31

5 Enter the 6 -1 1811 Value of day not Value of day not pass
M1, D2 in the range 1 ... in the range 1 ...
and Y2 31 31
cases
Value of year not Value of year not
in the range 1812 in the range 1812
... ...
2012 2012

6 Enter the -1 15 1811 Value of month Value of month pass


M2, D1 not in the range not in the range
and Y2 1 ... 12 1 ... 12
cases
Value of year not Value of year not
in the range 1812 in the range 1812
... ...
2012 2012

7 Enter the -1 -1 1811 Value of month Value of month pass


M2, D2 not in the range not in the range
and Y2 1 ... 12 1 ... 12
cases
Value of day not Value of day not
in the range 1 ... in the range 1 ...
31 31
Value of year not Value of year not
in the range 1812 in the range 1812
... ...
2012 2012

Some additional equivalence Boundary checking


Input data Expected output Actual output

Case Descripti Month Day Year Month Day Year Month Day Year Comment
id o
n

1 Enter the 12 31 1811 Value of year not Value of year not pass
M1 , D1 in the range 1812 in the range 1812
and Y2 ... ...
cases 2012 2012

2 Enter the 12 31 2012 1 1 2013 1 1 2013 pass


M1, D1
and Y1
cases
3 Enter the 12 31 2013 Value of year not Value of year not pass
M1, D1 in the range 1812 in the range 1812
... ...
2012 2012

and Y3
cases

Code:
#include<stdio.h>
int check(int day,int month)
{
if((month==4||month==6||month==9 ||month==11) && day==31)
return 1;
else
return 0;
}
int isleap(int year)
{
if((year%4==0 && year%100!=0) || year%400==0)
return 1;
else
return 0;
}
int main()
{
int day,month,year,tomm_day,tomm_month,tomm_year;
char flag;
do
{
flag='y';
printf("\nenter the today's date in the form of dd mm yyyy\n");
scanf("%d%d%d",&day,&month,&year);
tomm_month=month;
tomm_year= year;
if(day<1 || day>31)
{
printf("value of day, not in the range 1...31\n");
flag='n';
}
if(month<1 || month>12)
{
printf("value of month, not in the range 1....12\n");
flag='n';
}
else if(check(day,month))
{
printf("value of day, not in the range day<=30");
flag='n';
}
if(year<=1812 || year>2012)
{
printf("value of year, not in the range 1812...... 2012\n");
flag='n';
}
if(month==2)
{
if(isleap(year) && day>29)
{
printf("invalid date input for leap year");
flag='n';
}
else if(!(isleap(year))&& day>28)
{
printf("invalid date input for not a leap year");
flag='n';
}
}
}while(flag=='n');
switch (month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:if(day<31)
tomm_day=day+1;
else
{
tomm_day=1;
tomm_month=month+1;
}
break;
case 4:
case 6:
case 9:
case 11: if(day<30)
tomm_day=day+1;
else
{
tomm_day=1;
tomm_month=month+1;
}
break;
case 12: if(day<31)
tomm_day=day+1;
else
{
tomm_day=1;
tomm_month=1;
if(year==2012)
{
printf("the next day is out of boundary value of year\n");
tomm_year=year+1;
}
else
tomm_year=year+1;
}
break;
case 2:
if(day<28)
tomm_day=day+1;
else if(isleap(year)&& day==28)
tomm_day=day+1;
else if(day==28 || day==29)
{
tomm_day=1;
tomm_month=3;
}
break;
}
printf("next day is : %d %d %d",tomm_day,tomm_month,tomm_year);
return 0;
}

Output:
Dataflow testing
9) Write an application to calculate the bill of a cellular service customer depending
upon on his/her usage. The following calculates ‘Bill’ as per ‘Usage’ with the
following rules applicable. If ‘Bill’ is more than $100, 10% discount is given. Perform
data flow testing for all variables. Determine the output using test suite for variables.
Code:
#include<stdio.h>
void main()
{
float bill = 0.0;
int usage=0;
int c=1;

while(c!=-1)
{
printf("Enter usage:");
scanf("%d",&usage);

if(usage>0)
bill = 40;
if(usage > 100)
{
if(usage<=200)
bill = bill + (usage-100)*0.5;
else
{
bill = bill + 50+ (usage-200)*0.1;
if(bill>=100)
bill = bill*0.9;
}}
printf("\nBill: %f\n",bill);

printf("Continue?\n");
scanf("%d",&c);
}}

Output:
Strategy Bill Input Usage Expected Value Actual Output
Value

All Definition 1->2->10 0 0 0


(AD)

3->4->5->6 220 92 92

6->7 220 92 92

8->10 350 94.5 94.5

9->10 220 92 92

All c-use (ACU) 1->2->10 0 0 0

3->4->5->6 220 92 92

6->7->8 350 94.5 94.5

8->10 350 94.5 94.5

9->10 220 92 92
All p-use (APU) 1->2->3->4->5- 220 92 92
>6->7

3->4->5->6->7 220 92 92

6->7 220 92 92

All c-use + p 1->2->10 0 0 0


(ACU+P)

3->4->5->6 220 92 92

3->4->5->9 170 75 75

6->7->8 350 94.5 94.5

8->10 350 94.5 94.5

9->10 170 75 75

All p-use + c 1->2->3->4->5- 220 92 92


(APU + C) >6->7

3->4->5->6->7 220 92 92

6->7 220 92 92

8->10 350 94.5 94.5

9->10 170 75 75

All uses (AU) 3->4->5->6 220 92 92

6->7 220 92 92

6->7->8 350 94.5 94.5

8->10 350 94.5 94.5

3->4->5->9 170 75 75

10) For the code given below perform data flow testing for all variables. Determine
the output using test suite for variables.
Code:
import java.util.*;
public class computeStats {
public static void compute_Stats(int[] numbers)
{
int length = numbers.length;
double med=0.0, var=0.0, sd=0.0, mean=0.0, sum=0.0, varsum=0.0;
sum = 0.0;
// System.out.print(" 1 ");
int i =0;
// System.out.print(" 2 ");
// System.out.print(" 3 ");

// if(i<length)
// System.out.print(" 4 ");
for(i=0;i<length;i++)
{
sum +=numbers[i];
}

// System.out.print(" 5 ");
if(length>0)
{
med = numbers[length/2];
mean = sum / (double) length;

varsum = 0.0;

i=0;
// System.out.print(" 6 ");

// if(i<length)
// System.out.print(" 7 ");
for(i=0;i<length;i++)
{
varsum += (numbers[i]-mean) *(numbers[i]-mean);
}

// System.out.print(" 8 ");
if(length>1)
{
var = varsum/(length-1);

sd = Math.sqrt(var);
}

System.out.println();
System.out.println("length: "+length);
System.out.println("mean: "+mean);
System.out.println("median: "+med);
System.out.println("variance: "+var);
System.out.println("standard deviation: "+sd);

}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
int l = 0;
int c = 1;
do
{
System.out.println("Enter the length:");
l = in.nextInt();
int[] arr= new int[l];

System.out.println("Enter the elements:");


for(int i=0;i<l;i++)
{
arr[i] = in.nextInt();
}

//System.out.print("Path:");
compute_Stats(arr);

System.out.println("Do you want to continue?(1/0)");


c = in.nextInt();
}while(c==1);

Output:
Variable DU Path Input Expected Output Actual Output

Len Mean Med Var Stand L M Med Varie Stand


gth ian ien ard e e ian nce ard
ce Devia n a Devia
tion gt n tion
h
numbers 1->2->3->4 [1,1,1,1] 4 1 1 0 0 4 1 1 0 0

1->2->3->5 [] 0 0 0 0 0 0 0 0 0 0

1->2->3->5- [] 0 0 0 0 0 0 0 0 0 0
>6- >7

Length 1->2->3->5 [] 0 0

1->2->3->5- [1, 2, 3, 5 3 3 2.5 1.58 5 3 3 2.5 1.581


>6- >8 4, 1
5]

1->2->3->4 [1,1,1,1] 4 1 1 0 0 4 1 1 0 0

1->2->3->5- [1,1,1,1] 4 1 1 0 0 4 1 1 0 0
>6- >7

Med 5->6->8 [1, 2, 3, 5 3 3 2.5 1.58 5 3 3 2.5 1.581


4, 1
5]

Sum 1->2->3->4 [1,1,1,1] 4 1 1 0 0 4 1 1 0 0

1->2->3->5 [] 0 0 0 0 0 0 0 0 0 0

4->3->4 [1,1,1,1] 4 1 1 0 0 4 1 1 0 0

4->3->5 [1] 1 1 1 0 0 1 1 1 0 0

mean 5->6->7 [1,2,3,4] 4 2.5 3 1.6 1.29 4 2 3 1.66 1.29


66 . 6
5

5->6->8 [] 0 0 0 0 0 0 0 0 0 0

varsum 5->6->7 [1,2,3,4] 4 2.5 3 1.6 1.29 4 2 3 1.66 1.29


66 . 6
5

5->6->8 [] 0 0 0 0 0 0 0 0 0 0

7->6->7 [1,2,3,4] 4 2.5 3 1.6 1.29 4 2 3 1.66 1.29


66 . 6
5
7->6->8 [1] 1 1 1 0 0 1 1 1 0 0

i 2->3->4 [1,2,3,4] 4 2.5 3 1.6 1.29 4 2 3 1.66 1.29


66 . 6
5

2->3->5 [] 0 0 0 0 0 0 0 0 0 0

4->3->4 [1,2,3,4] 4 2.5 3 1.6 1.29 4 2 3 1.66 1.29


66 . 6
5

4->3->5 [1] 1 1 1 0 0 1 1 1 0 0

5->6->7 [1,2,3,4] 4 2.5 3 1.6 1.29 4 2 3 1.66 1.29


66 . 6
5

5->6->8 [] 0 0 0 0 0 0 0 0 0 0

7->6->7 [1,2,3,4] 4 2.5 3 1.6 1.29 4 2 3 1.66 1.29


66 . 6
5

7->6->8 [1] 1 1 1 0 0 1 1 1 0 0

12.) The Calendar application has classes: CalendarUnit, testIT, Date, Day, Month,
Year. Perform object oriented integration testing.

Go to File > New > Java Project


Project Name: Calendar Application then click on Finish
To create classes, click on the project name in the Project Explorer
Left click> New > Class then make the following classes: class:
CalendarUnit

public abstract class CalendarUnit {


int currentPos;

CalendarUnit(){}

CalendarUnit(int p)
{
currentPos = p;
}

public void setCurrentPos(int p)


{
currentPos = p;
}

protected abstract boolean increment();


}

class: testIT
import java.util.*;
public class testIT {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter the day, month, year: ");
int day = in.nextInt();
int month = in.nextInt();
int year = in.nextInt();
Year testYear = new Year(year);
Month testMonth = new Month(month, testYear);
Day testDay = new Day(day, testMonth);
Date testDate = new Date(testDay, testMonth, testYear);
testDate.increment();
testDate.printDate();
}
}class:Date
public class Date
{
private Day d;
private Month m;
private Year y;
Date(Day d1, Month m1, Year y1)
{
d = d1;
m = m1;
y = y1;
}

public void increment()


{
if(!d.increment())
{
if(!m.increment())
{
y.increment();
m.setMonth(1,y);
}
else
d.setDay(1,m);
}
}
public void printDate()
{
System.out.println(m.getMonth()+"/"+d.getDay()+"/"+y.getYear());
}

class: Day
public class Day extends CalendarUnit
{
Month m;
Day(int d, Month m1)
{
super();
setDay(d, m1);
}
public void setDay(int d, Month m1)
{
setCurrentPos(d);
m = m1;
}
public int getDay()
{
return currentPos;
}

public boolean increment()


{
currentPos = currentPos + 1;
if(currentPos <= m.getMonthSize())
return true;
else
return false;
}
}

class: Month
public class Month extends CalendarUnit
{
Year y;
private int[] sizeIndex = new int[] { 31,28,31,30,31,30,31,31,30,31,30,31};
Month(int m, Year y1)
{
setMonth(m, y1);
}
public void setMonth(int m, Year y1)
{
setCurrentPos(m);
y = y1;
}
public int getMonth()
{
return currentPos;
}
public int getMonthSize()
{
if(y.isleap())
sizeIndex[1] = 29;
else
sizeIndex[1] = 28;
return sizeIndex[currentPos-1];

}
public boolean increment()
{
currentPos = currentPos + 1;
if(currentPos>12)
return false;
else
return true;
}
}

class: Year
public class Year extends CalendarUnit
{
Year(int y1)
{
setCurrentPos(y1);
}

public int getYear()


{
return currentPos;
}

public boolean increment()


{
currentPos = currentPos + 1;
return true;
}

public boolean isleap()


{
if(((currentPos%4==0)&& !(currentPos%100==0)) || (currentPos%400==0))
return true;
else
return false;
}
}

Output:

Selenium problem:

Launch Eclipse IDE


Create a new Java Project from File > New > Java Project

Give Project name as "selenium", leave the other fields unaltered and click on
"Finish" button.

It will create a new Java project with the following directories.


Right click on the "src" folder and create a new Class File from New >
Class. Give your Class name as "selenium test" and click on "Finish" button.
Now, we will add the Selenium jar files in our Test Suite (selenium).

Right click on "selenium" folder and select Properties.

It will launch the Properties window for our "selenium" Test Suite.

Click on "Java Build Path" option from the left hand side panel.
Switch to Libraries tab and click on "Add External JARs" button. Locate the directory where
you have downloaded the Selenium jar files, select the respective jars and click on "Open"
button. Repeat the same steps for the jars which are present under the "libs" folder. Open
"libs" folder, select all of the respective jar files and click on "Open" button. Once you get all
the Selenium jar files in your Libraries tab, click on Apply and Close button.

The following image shows the directory structure of our "selenium" test suite after adding
Selenium jars.
Hence, we have successfully configured Selenium WebDriver with Eclipse IDE. Now, we are
ready to write our test scripts in Eclipse and run it in WebDriver.

13) Configure Selenium WebDriver with Eclipse IDE and create Selenium Automation
Test script. Under this test, automate the following scenarios:
a. Invoke Google Chrome browser, Open URL: www.google.com, Click on the Google
Search text box, Type the value "BMS College of Engineering", Click on the Search button.
b. Invoke Google Chrome browser, Open URL: www.isearch123.com, Click on the Google
Search text box, Type the value "BMS College of Engineering", Click on the Search button.
c. Invoke Google Chrome browser, Open Indeed home page, https://www.indeed.co.uk/ ,
Find What field and enter Selenium.
Step1. Launch Eclipse IDE and open project "selenium" which we have created in the
previous section (Configure Selenium WebDriver) of this Tutorial. We will write our first
Selenium test script in the "SeleniumTest.class" file under the "selenium" test suite.

Step2. Open URL: https://sites.google.com/a/chromium.org/chromedriver/downloads in


your browser.

Step3. Click on the "ChromeDriver 2.41" link. It will redirect you to the directory of
ChromeDriver executables files. Download as per the operating system you are currently
on.

For windows, click on the "chromedriver_win32.zip" download.

The downloaded file would be in zipped format. Unpack the contents in a


convenient directory.

Step4. We would need a unique identification for the web elements like Google Search text
box and Search button in order to automate them through our test script. These unique
identifications are configured along with some Commands/Syntax to form Locators. Locators
help us to locate and identify a particular web element in context of a web application.

The method for finding a unique identification element involves inspection of HTML codes.
- Open URL: https://www.google.com in your Chrome browser.
Right click on the Google search text box and select Inspect Element
Code: (Uncomment and run the parts one by one)
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;;
public class First {
public static void main(String[] args)
{
System.setProperty("webdriver.chrome.driver","C:\\Users\\admin\\Downloads\\chrom
edriver_win32\\chromedriver.exe");

WebDriver driver = new ChromeDriver();


driver.manage().window().maximize();

// driver.navigate().to("http://www.google.com/");
// driver.findElement(By.name("q")).sendKeys("BMS College of Engineering"); //
driver.findElement(By.name("btnK")).click();

// driver.navigate().to("http://www.isearch123.com/");
// driver.findElement(By.name("q")).sendKeys("VTU");
// driver.findElement(By.className("btn")).click();

// driver.navigate().to("https://www.indeed.co.uk/");
// driver.findElement(By.name("q")).sendKeys("Selinium"); //
driver.findElement(By.className("icl-Button icl-Button--primary icl-Button-- md
icl-WhatWhere-button")).click();
}
}

OUTPUT: (Demo_Test> src > > First.java > (Right Click) > Run As > Java Application
14)Create Selenium IDE Script to perform the following
processes: • Process #1: Recording a test script
• Process #2: Playing back / executing a test script
• Process #3: Saving a test script

Open “https://accounts.google.com”.

Assert Title of the application

Enter a valid username and password and submit the details to login.

Verify that the user is redirected to the Home page.

Step 1 – Launch the Firefox and open Selenium IDE from the menu bar. Click on “Create
a new project”. Enter project name.
Step 2 – Click on Record button. Enter the address of application under test
(“https://accounts.google.com”) inside the Base URL textbox. Click on Start
Recording.

Step 3: Log in to mail id


Step 4: In Selenium IDE, look for the following: assert tile, username and password.

Process #2: Playing back / executing a test script


Click on the playback button to run current test case. If more than one test case is present
then, all tests can be executed by clicking Run all tests playback button.

After executing test case, test case successful is displayed.

Process #3: Saving a test script


Click on the export option and save as Java Junit. The exported file is saved as
“signup.java” (or any user defined name, .java is the extension).
The project is saved using save option. The extension would be

“.side”.

The java file exported can be viewed in eclipse IDE.

You might also like