Note: These are Diploma 5th sem Software Testing lab programs, only for diploma students
Combocount.java
import com.thoughtworks.selenium.*;
@SuppressWarnings("deprecation")
public class combocount extends SeleneseTestCase
{
public void setUp() throws Exception
{
setUp("http://","*firefox");
}
public void testcombolistcount()
{
selenium.setSpeed("2000");
selenium.open("http://www.facebook.com/");
selenium.waitForPageToLoad("30000");
selenium.windowMaximize();
String[] selectelement= new String[1000];
selectelement= selenium.getSelectOptions("id=day");
System.out.println("the no_of items present in the given combobox day="+selectelement.length);
selectelement= selenium.getSelectOptions("id=month");
System.out.println("the no_of items present in the given combobox month="+selectelement.length);
selectelement= selenium.getSelectOptions("id=year");
System.out.println("the no_of items present in the given combobox year= "+selectelement.length);
}
}
dataupdate.java
import java.io.*;
import jxl.Cell;
import jxl.Workbook;
import jxl.Sheet;
import jxl.read.biff.BiffException;
public class dataupdate1
{
private String inputFile="/home/student/Desktop/student.ods";
public void read() throws IOException
{
File inputWorkbook=new File(inputFile);
Workbook w;
int count=0;
try
{
w=Workbook.getWorkbook(inputWorkbook);
Sheet sheet=w.getSheet(0);
System.out.println("student storing more than 60 in any one or more subject are:");
for(int j=1; j<sheet.getRows(); j++)
{
for(int i=1; i<sheet.getColumns(); i++)
{
Cell box=sheet.getCell(i,j);
if(Integer.parseInt(box.getContents())>60)
{
count++;
Cell name_cell=sheet.getCell(0,j);
System.out.print(name_cell.getContents());
break;
}
}
}
System.out.println("student storing more than 60 in any one or more subject are:"+count);
}
catch(BiffException e)
{
e.printStackTrace();
}
}
public static void main(String[] args)throws IOException
{
dataupdate1 test=new dataupdate1();
test.read();
}
}
desktopitemcount
import java.io.*;
public class desktopitemcount
{
public static void main(String[]args)
{
File f=new File("/home/student/Desktop");
File[]listOfFiles=f.listFiles();
int fi=0,d=0;
for(int i=0; i<listOfFiles.length;i++)
{
if(listOfFiles[i].isFile())
{
fi++;
System.out.println("file="+listOfFiles[i].getName());
}
else if(listOfFiles[i].isDirectory())
{
d++;
System.out.println("directory="+listOfFiles[i].getName());
}
}
System.out.println("no_of file="+fi);
System.out.println("no_of directories="+d);
}
}
login
import com.thoughtworks.selenium.*;
@SuppressWarnings("deprecation")
public class login extends SeleneseTestCase
{
public void setUp() throws Exception
{
setUp("http://php.thedemosite.co.uk","*firefox");
}
public void testloginlogout()
{
selenium.setSpeed("2000");
selenium.open("login.php");
selenium.windowMaximize();
selenium.type("//input[@name='username']","sdmmm");
selenium.type("//input[@name='password']","sdmmm");
selenium.click("//input[@type='button']");
selenium.waitForPageToLoad("50000");
selenium.type("//input[@name='username']","Lannister");
selenium.type("//input[@name='password']","dran1$");
selenium.click("//input[@type='button']");
selenium.waitForPageToLoad("50000");
}
}
objectcount.java
import com.thoughtworks.selenium.*;
@SuppressWarnings("deprecation")
public class objectcount extends SeleneseTestCase
{
public void setUp() throws Exception
{
setUp("http://sirigannadanadi.blogspot.com/","*firefox");
}
public void testloginlogout()
{
selenium.setSpeed("10000");
selenium.open("/");
selenium.waitForPageToLoad("2000");
selenium.windowMaximize();
String lc[]=selenium.getAllLinks();
System.out.println("totl no_of links are="+lc.length);
String bc[]=selenium.getAllButtons();
System.out.println("totl no_of buttons are="+bc.length);
String fc[]=selenium.getAllFields();
System.out.println("totl no_of fields are="+fc.length);
}
}
studentrecords
import java.io.*;
import jxl.*;
import jxl.write.*;
import jxl.write.Number;
import jxl.write.biff.RowsExceededException;
public class studebtrecords
{
private String ifile="/home/student/Desktop/student.ods";
{
File xlfile=new File(ifile);
WritableWorkbook wb=Workbook.createWorkbook(xlfile);
wb.createSheet("Report",0);
WritableSheet excelsheet= wb.getSheet(0);
createContent (excelsheet);
wb.write();
wb.close();
}
private void createContent(WritableSheet Sheet)
throws WriteException,RowsExceededException
{
addLable(Sheet,0,0,"reg.no");
addLable(Sheet,1,0,"nsm");
addLable(Sheet,2,0,"Ism");
addLable(Sheet,3,0,"st");
for(int i=0; i<10; i++)
{
addLable(Sheet,0,i+1,"497cs1601"+(i));
addNumber(Sheet,1,i+1,(i*i)+10);
addNumber(Sheet,2,i+1,(i*i)+15);
addNumber(Sheet,3,i+1,(i*i)+13);
}
}
private void addNumber(WritableSheet Sheet,int column,int row,Integer integer)throws WriteException,RowsExceededException
{
Number number;
number=new Number(column,row,integer);
Sheet.addCell(number);
}
private void addLable (WritableSheet Sheet,int column,int row,String s)throws WriteException,RowsExceededException
{
Label lable;
lable=new Label(column,row,s);
Sheet.addCell(lable);
}
public static void main(String[] args)throws WriteException,IOException
{
studebtrecords test=new studebtrecords();
test.write();
System.out.println("please check the result file in folder ");
}
}
employee
import java.io.*;
import jxl.Cell;
import jxl.Workbook;
import jxl.Sheet;
import jxl.read.biff.BiffException;
public class Emp
{
private String inputFile="/home/student/Desktop/employee.xls";
public void read() throws IOException
{
File inputWorkbook=new File(inputFile);
Workbook w;
int c=0;
try
{
w=Workbook.getWorkbook(inputWorkbook);
Sheet sheet=w.getSheet(0);
System.out.println("employee who is gaining salary above 50000 and age between 30 and 40");
for(int j=1; j<sheet.getRows(); j++)
{
for(int i=1; i<sheet.getColumns(); i++)
{
Cell box=sheet.getCell(2,j);
Cell box=sheet.getCell(1,j);
if(Integer.parseInt(box.getContents())> 50000 && (Integer.parseInt(b1.getContents()> 30)
{
c++;
Cell name=sheet.getCell(0,j);
System.out.print(name.getContents());
break;
}
}
}
System.out.println("total number of employee who are drawing salary above 50000"+c);
}
catch(BiffException e)
{
e.printStackTrace();
}
}
public static void main(String args[])throws IOException
{
Emp test=new Emp();
test.read();
}
}
testsuit
/*<html>
<head><title>Arithmatic operation</title>
<script type="text/javascript">
function Add()
{
var a=document.myform.n1.value;
var b=document.myform.n2.value;
a=ParseInt(a);
b=ParseInt(b);
var c=a+b;
document.myform.result.value=c;
}
function Subtract()
{
var a=document.myform.n1.value;
var b=document.myform.n2.value;
a=ParseInt(a);
b=ParseInt(b);
var c=a-b;
document.myform.result.value=c;
}
function multiply()
{
var a=document.myform.n1.value;
var b=document.myform.n2.value;
a=ParseInt(a);
b=ParseInt(b);
var c=a*b;
document.myform.result.value=c;
}
function division()
{
var a=document.myform.n1.value;
var b=document.myform.n2.value;
a=ParseInt(a);
b=ParseInt(b);
var c=a/b;
document.myform.result.value=c;
}
</script></head><body>
<form name ="myform"><center><br>
enter number1:<input type="text" id="n1"><br>
enter number2:<input type="text" id="n1"><br>
<input type="button" value="ADD"onclick=ADD();">
<input type="button" value="SUB"onclick=Subtract();">
<input type="button" value="MUL"onclick=Multiply();">
<input type="button" value="DIV"onclick=Division();">
Result:<input type="text"name="result">
</center>
</form>
</body>
</html>*/
Comments
Post a Comment