0% found this document useful (0 votes)
15 views56 pages

STQA

Uploaded by

shijingeorge3
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)
15 views56 pages

STQA

Uploaded by

shijingeorge3
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

Prac1 ^

<?php
$rno=$_POST["txtrno"];
$name=$_POST["txtname"];
$m1=$_POST["m1"];
$m2=$_POST["m2"];
$m3=$_POST["m3"];
$tot=$m1+$m2+$m3;
$per=$tot/3.0;
echo "Roll no=".$rno."<br>";
echo "Name=".$name."<br>";
echo "Maths=".$m1."<br>";
echo "Physics=".$m2."<br>";
echo "Chemistry=".$m3."<br>";
echo "Total=".$tot."<br>";
echo "Percentage=".$per."<br>";
if($m1<35||$m2<35||$m3<35)
echo "fail";
else
if($per<50)
echo "Pass";
else
if($per<60)
echo "Second";
else
if($per<75)
echo "First class";
else
echo "Distinction";
?>

result.php^

OUTPUT:
Testcases
PRACTICAL 2

<html>
<head><title>Shopping website</title></head>
<body>
<form method="POST" action="shopping.php">
Enter type of user:
<select name="user">
<option value="0">Select user</option>
<option value="1">Guest user</option>
<option value="2">Customer</option>
</select>
<br>
Do you have a gift card?
<select name="gift">
<option value="0">Select</option>
<option value="1">Yes</option>
<option value="2">No</option>
</select>
<br>
<input type=submit value="submit">
</form>
</body>
</html>

Shopping.php
<?php
$user=$_POST["user"];
$gift=$_POST["gift"];
if(($user=="0")||($gift=="0"))
echo "Invalid input";
else
if($user=="1")
{
if($gift=="1")
echo"You are eligible for 20% discount";
else
echo"You are eligible for 15% discount";
}
else
{
if($user=="2")
{
if($gift=="1")
echo"you are eligible for 20% discount";
else
echo"you are not eligible for discount";
}
}
?>

OUTPUT
PRACTICAL 3-GCD

<html>
<head><title>GCD</title>
<script language="javascript">
function gcd()
{
var x,y;
x=parseInt(document.f1.t1.value);
y=parseInt(document.f1.t2.value);
while(x!=y)
{
if(x>y)
x=x-y;
else
y=y-x;
}
document.f1.t3.value=x;
}
</script>
</head>
<body>
<h1>Program to find GCD of two numbers</h1>
<form name="f1">
Enter first number:<input type=text name="t1"><br>
Enter second number:<input type=text name="t2"><br>
<input type="button" name="btn" value="find GCD" onClick="gcd()">
GCD:<input type=text name="t3"><br>
</form>
</body>
</html>

OUTPUT
:

GCD
Find gcd of two numbers
<html>
<head><title>GCD</title>
<script language="javascript">
function gcd()
{
var x=parseInt(document.f1.t1.value);
var y=parseInt(document.f1.t2.value);
while(x!=y)
{
if(x>y)
x=x-y;
else
y=y-x;
}
document.f1.t3.value=x;
}
</script>
</head>
<body>
<form name="f1">
<h1>Program for GCD of two numbers</h1>
Enter first number:<input type="text" name="t1"><br>
Enter second number:<input type="text" name="t2"><br>
GCD of two numbers:<input type="text" name="t3"><br>
<input type="button" name="btn" value="Find GCD" onClick="gcd()">
</form>
</body>
</html>
PRACTICAL 4-LOGIN a)php login chrome b)facebook chrome c)facebook firefox
PRACTICAL 5
FACTORIAL
Factclass.java
package FactorialPackage;

public class factclass {


public int factorial(int n)
{
int fact=1;
while(n>0)
{
fact=fact*n;
n--;
}
return(fact);
}

public static void main(String[] args) {


// TODO Auto-generated method stub

factorial.java
package FactorialPackage;

import static org.junit.Assert.*;

import org.junit.Test;
public class factorial {

@Test
public void testfactorial() {
factclass f1=new factclass();
int f=f1.factorial(5);
assertEquals(f,120);
}

Output:

Wrong output:
PRACTICAL 6-Addition,sub,mul,div
Arthmetic_Class
package arthmetic;

public class Arthmetic_Class


{
public int addition(int a,int b)
{
int c=a+b;
return(c);
}
public int subtraction(int a,int b)
{
int c=a-b;
return(c);
}
public int multiplication(int a,int b)
{
int c=a*b;
return(c);
}
public int division(int a,int b)
{
int c=a%b;
return(c);
}
public static void main(String[] args)
{

}
}

arithmetic.java
package arthmetic;

import static org.junit.Assert.*;

import org.junit.Test;

public class arthmetic {

@Test
public void testarthmetic() {
Arthmetic_Class a1=new Arthmetic_Class();
int f=a1.addition(2, 2);
assertEquals(f,4);
}

O/p

Subtraction
Multiplication

Division
REVERSE PROGRAM
reverseClass.java
package reverse;
public class reverseClass
{
public int reverse(int num)
{
int reversed = 0;
while(num != 0)
{
int digit = num % 10;
reversed = reversed * 10 + digit;
num /= 10;
}
return(reversed);
}
public static void main(String[] args) {
}}

reverse.java
package reverse;
import static org.junit.Assert.*;
import org.junit.Test;
public class reverse {
@Test
public void testreverse() {
reverseClass r1=new reverseClass();
int f=r1.reverse(123);
assertEquals(f,321);
}}
O/P:

package reverse;
import static org.junit.Assert.*;
import java.util.Scanner;
import org.junit.Test;
public class reverset {
@Test
public void testreverse() {
System.out.println("Enter the number: ");
Scanner sc=new Scanner(System.in);
int p1=sc.nextInt();
System.out.println("Enter the expected value: ");
int exp=sc.nextInt();
revClass r1=new revClass();
int n1=r1.reverse(p1);
assertEquals(n1,exp);
}}

Output:
UNIT TESTING PROGRAM digits of sum(just for practice)
sum.java
package sumofdigits;
import java.util.Scanner;
public class sum
{
public int digits(int number)
{
int digit,sum = 0;
while(number > 0)
{
digit = number % 10;
sum = sum + digit;
number = number / 10;
}
return sum;
}
public static void main(String[] args)
{

}
}

digit.java
package sumofdigits;
import java.util.Scanner;
import static org.junit.Assert.*;

import org.junit.Test;

public class digit {

@Test
public void testsum() {
int n,n1;
sum r1=new sum();
Scanner sc=new Scanner(System.in);
System.out.print("Enter the number: ");
n=sc.nextInt();
System.out.print("Enter the expected sum of digits: ");
n1=sc.nextInt();
int s=r1.digits(n);
assertEquals(s,n1);
}

}
B1->12-08-2024
PRAC 6A
ExcelupdateClasss.java
package ExcelupdatePackage;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import jxl.Sheet;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;

public class ExcelupdateClass {


@BeforeClass
public void f1()
{}
@Test
public void testImportexport() throws Exception{
FileInputStream fi=new
FileInputStream("D:\\TYCS_RANJEET_TecH_RC\\selenium pracs\\myBook1.xls");
Workbook w=Workbook.getWorkbook(fi);
Sheet s=w.getSheet(0);
String a[][]=new String[s.getRows()][s.getColumns()];
FileOutputStream fo=new
FileOutputStream("D:\\TYCS_RANJEET_TecH_RC\\selenium pracs\\myBook1res.xls");
WritableWorkbook wwb=Workbook.createWorkbook(fo);
WritableSheet ws=wwb.createSheet("result1",0);
for(int i=0;i<s.getRows();i++)
for(int j=0;j<s.getColumns();j++)
{
a[i][j]=s.getCell(j,i).getContents();
Label l2=new Label(j,i,a[i][j]);
ws.addCell(l2);
Label l1=new Label(6,0,"Result");
ws.addCell(l1);
}
for(int i=1;i<s.getRows();i++){
for(int j=2;j<s.getColumns();j++)
{
a[i][j]=s.getCell(j,i).getContents();
int x=Integer.parseInt(a[i][j]);
if(x>=35)
{
Label l1=new Label(6,i,"pass");
ws.addCell(l1);
}
else
{
Label l1=new Label(6,i,"fail");
ws.addCell(l1);
break;} }
}
wwb.write();
wwb.close();
}

public static void main(String[] args) {


// TODO Auto-generated method stub

}
Add jxl file through add external jar files

PRAC 6 B
package combop;
import jxl.Cell;
import jxl.read.biff.BiffException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.*;
import jxl.write.*;
import java.io.*;
import jxl.*;
public class count
{
@BeforeClass
public void f1()
{}
@Test
public void test2() throws Exception
{
FileInputStream fi=new
FileInputStream("D:\\TYCS_RANJEET_TecH_RC\\selenium pracs\\myBook1.xls");
Workbook w=Workbook.getWorkbook(fi);
Sheet s=w.getSheet(0);
String a[][]=new String[s.getRows()][s.getColumns()];
FileOutputStream fo=new
FileOutputStream("D:\\TYCS_RANJEET_TecH_RC\\selenium pracs\\myBook1res.xls");
WritableWorkbook wwb=Workbook.createWorkbook(fo);
WritableSheet ws=wwb.createSheet("result1",0);
int c=0;
for(int i=0;i<s.getRows();i++)
for(int j=0;j<s.getColumns();j--)
{
if(i>=1)
{
String b=new String();
b=s.getCell(3,i).getContents();
int x=Integer.parseInt(b);
if(x<60)
{
c++;
break;
}
}
a[i][j]=s.getCell(j,i).getContents();
Label l2=new Label(j,i-c,a[i][j]);
ws.addCell(l2);
}
wwb.write();
wwb.close();
}
}

Output:
5/08/24
Prac8
Save in wamp64 -> www folder
state.html
<html>
<head>
<title>States</title>
</head>
<body>
<form name="f1" action="POST">
States:
<select id="statename">
<option>Maharashtra</option>
<option>Kerala</option>
<option>Jammu&Kashmir</option>
<option>Manipur</option>
</select>
</form>
</body>
</html>

Combo
package combopack;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
public class combo {

public static void main(String[] args) {

System.setProperty("webdriver.firefox.marionette","D:\\TYCS_RANJEET_TecH_RC\\Seleniu
m\\geckodriver.exe");
WebDriver driver=new FirefoxDriver();
driver.get("http://localhost/state.html");
Select selectDropdown=new Select(driver.findElement(By.id("statename")));

java.util.List<WebElement>optionCount=driver.findElements(By.xpath("//select/option"));
System.out.println("Total number of item count in dropdown
list="+optionCount.size());
for(int i=0;i<optionCount.size();i++)
{
System.out.println(optionCount.get(i).getText());
}

}
Output:
5/8/2024
package prac7;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebElement;
public class prac6
{
public static void main(String[] args)
{

System.setProperty("webdriver.firefox.marionette","D:\\TYCS_RANJEET_Tec
H_RC\\Selenium\\geckodriver.exe");
WebDriver driver=new FirefoxDriver();
driver.get("https://www.rediff.com");

java.util.List<WebElement>links=driver.findElements(By.tagName("a"));
System.out.print("Total links are="+links.size());
for(int i=0;i<links.size();i++)
{
System.out.println("Link"+i+"Link
Name"+links.get(i).getText());

}
}

Output:
Prac 9 26/08/2024
hobbies.html
<html>
<head><title>Hobby</title></head>
<body>
<form method="POST">
Hobbies:
<input type="checkbox" id="c1" value="dance">Dancing<br>
<input type="checkbox" id="c2" value="draw">Drawing<br>
<input type="checkbox" id="c3" value="sing">Singing<br>
<input type="checkbox" id="c4" value="trek">Trekking<br>
<input type="checkbox" id="c5" value="cook">Cooking<br>
</form>
</body>
</html>

Check
package checkbox;
Import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebElement;
public class check
{
public static void main(String[] args)
{

System.setProperty("webdriver.firefox.marionette","D:\\TYCS_RANJEET_Tec
H_RC\\Selenium\\geckodriver.exe");
WebDriver driver=new FirefoxDriver();
driver.get("http://localhost/hobbies.html");
driver.findElement(By.xpath("//input[@value='dance']")).click();
driver.findElement(By.xpath("//input[@value='draw']")).click();
java.util.List<WebElement>
elements=driver.findElements(By.xpath("//input[@type='checkbox']"));
int checkedcount=0;
int uncheckedcount=0;
for(int i=0;i<elements.size();i++)
{
if(elements.get(i).isSelected()==true)
checkedcount++;
else
uncheckedcount++;
}
System.out.println("Number of checked checkboxes
are:"+checkedcount);
System.out.println("Number of unchecked checkboxes
are:"+uncheckedcount);
}
}

Output:
Jmeter

You might also like