Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Excelsheet
1. package excelImport;
import com.thoughtworks.selenium.*;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.Writer;
import jxl.*;
public class dataDriven1 extends SeleneseTestCase {
public void ultimatixInfo()throws Exception
{
try
{
selenium = new DefaultSelenium("localhost",4444,"*firefox C:Documents
and Settings377075My DocumentsMozilla Firefox 10.1Mozilla
Firefoxfirefox.exe","https://www.gooole.com/");
selenium.start();
selenium.open("/");
//Reading Login Info from excel sheet from one location in Computer
Workbook workbook = Workbook.getWorkbook(new File("C:Documents and
Settings377075test1.xls"));
Sheet sheet = workbook.getSheet(0);
int row_count = sheet.getRows();
int i=0;
String user = null, pw = null;
//System.out.println(row_count);
for(int j=0;j<row_count-1;j++)
{
if(sheet.getCell(i,i).getContents().equalsIgnoreCase("uname"))
{
user=sheet.getCell(i,j+1).getContents();
//System.out.println(user);
}
if(sheet.getCell(i+1,i).getContents().equalsIgnoreCase("password"))
{
pw=sheet.getCell(1,j+1).getContents();
//System.out.println(pw);
}
//Login in ultimatix page with data obtained from excel sheet
selenium.type("id=USER",user);
selenium.type("id=PASSWORD",pw);
selenium.click("id=login_button");
selenium.waitForPageToLoad("90000");
//Reading User's Role Info from ultimatix account
String Role =
selenium.getText("xpath=html/body/div[1]/div[1]/table/tbody/tr/td/table/tbody/tr
[2]/td/table/tbody/tr/td[2]/div[2]/span[2]");
//Reading User's Name from ultimatix account
String Name =
selenium.getText("xpath=html/body/div[1]/div[1]/table/tbody/tr/td/table/tbody/tr
[2]/td/table/tbody/tr/td[2]/div[2]/span[1]");
//Opening a new text file at one location and writing the User's Info
there
File file = new File("C://Documents and Settings/377075/My
Documents/Downloads//write.txt");
Writer output = null;
output = new BufferedWriter(new FileWriter(file));