import static org.junit.Assert.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestCase;
public class Vskill_excel extends SeleneseTestCase {
@Before
public void setUp() throws Exception {
SeleniumServer ss = new SeleniumServer();
ss.start();
selenium= new DefaultSelenium("localhost", 4444, "firefox", "http://");
selenium.start();
}
@After
public void tearDown() throws Exception {
}
@Test
public void test() throws InterruptedException, BiffException, IOException {
selenium.open("www.vskills.in/certification/register");
Thread.sleep(10000);
selenium.windowMaximize();
Thread.sleep(2000);
FileInputStream fis = new FileInputStream("D:\\Vskill.xls");//Getting Excel Path
Workbook wb = Workbook.getWorkbook(fis);//Getting workbook or Excel
Sheet s = wb.getSheet(0);//going to sheet
Thread.sleep(5000);
selenium.highlight("//*[@id='content']/form/div[1]/table/tbody/tr[1]/td[2]/input");
selenium.type("//*[@id='content']/form/div[1]/table/tbody/tr[1]/td[2]/input",s.getCell(0, 1).getContents());
Thread.sleep(3000);
selenium.highlight("//*[@id='content']/form/div[1]/table/tbody/tr[2]/td[2]/input");
Thread.sleep(3000);
selenium.type("//*[@id='content']/form/div[1]/table/tbody/tr[2]/td[2]/input", s.getCell(1, 1).getContents());
Thread.sleep(3000);
selenium.highlight("//*[@id='content']/form/div[1]/table/tbody/tr[4]/td[2]/input");
Thread.sleep(3000);
selenium.type("//*[@id='content']/form/div[1]/table/tbody/tr[4]/td[2]/input", s.getCell(3, 1).getContents());
Thread.sleep(3000);
selenium.highlight("//*[@id='content']/form/div[1]/table/tbody/tr[5]/td[2]/input");
Thread.sleep(3000);
selenium.type("//*[@id='content']/form/div[1]/table/tbody/tr[5]/td[2]/input", s.getCell(4, 1).getContents());
Thread.sleep(3000);
selenium.captureScreenshot("D:\\sudheer\\vskill.png");
}
}
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestCase;
public class Vskill_excel extends SeleneseTestCase {
@Before
public void setUp() throws Exception {
SeleniumServer ss = new SeleniumServer();
ss.start();
selenium= new DefaultSelenium("localhost", 4444, "firefox", "http://");
selenium.start();
}
@After
public void tearDown() throws Exception {
}
@Test
public void test() throws InterruptedException, BiffException, IOException {
selenium.open("www.vskills.in/certification/register");
Thread.sleep(10000);
selenium.windowMaximize();
Thread.sleep(2000);
FileInputStream fis = new FileInputStream("D:\\Vskill.xls");//Getting Excel Path
Workbook wb = Workbook.getWorkbook(fis);//Getting workbook or Excel
Sheet s = wb.getSheet(0);//going to sheet
Thread.sleep(5000);
selenium.highlight("//*[@id='content']/form/div[1]/table/tbody/tr[1]/td[2]/input");
selenium.type("//*[@id='content']/form/div[1]/table/tbody/tr[1]/td[2]/input",s.getCell(0, 1).getContents());
Thread.sleep(3000);
selenium.highlight("//*[@id='content']/form/div[1]/table/tbody/tr[2]/td[2]/input");
Thread.sleep(3000);
selenium.type("//*[@id='content']/form/div[1]/table/tbody/tr[2]/td[2]/input", s.getCell(1, 1).getContents());
Thread.sleep(3000);
selenium.highlight("//*[@id='content']/form/div[1]/table/tbody/tr[4]/td[2]/input");
Thread.sleep(3000);
selenium.type("//*[@id='content']/form/div[1]/table/tbody/tr[4]/td[2]/input", s.getCell(3, 1).getContents());
Thread.sleep(3000);
selenium.highlight("//*[@id='content']/form/div[1]/table/tbody/tr[5]/td[2]/input");
Thread.sleep(3000);
selenium.type("//*[@id='content']/form/div[1]/table/tbody/tr[5]/td[2]/input", s.getCell(4, 1).getContents());
Thread.sleep(3000);
selenium.captureScreenshot("D:\\sudheer\\vskill.png");
}
}
ReplyDeleteGreat Article! This blog is useful for everyone. Turnao is a web-based application used to Convert excel spreadsheet to online database.