package exceldata;
import java.io.FileInputStream;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class excel_data
{
public static Object[][] readdata() throws Throwable
{
FileInputStream input_file = new FileInputStream("/Users/rashmimohan/Desktop/Selenium_IDE/TestData_RumasCollection.xlsx");
XSSFWorkbook workbook = new XSSFWorkbook(input_file);
XSSFSheet sheet = workbook.getSheet("Sheet 1");
int rowCount = sheet.getLastRowNum();
int column = sheet.getRow(0).getLastCellNum();
System.out.println(rowCount);//2
System.out.println(column);//17
DataFormatter d = new DataFormatter();
int row=2, col=1;
Object[][] data = new Object[3][17];
for( row=2;row<=2;row++)
{
for( col=1;col<=16;col++)
{
System.out.println("COL FOR LOOP " +row +" " +col);
data[row][col] = d.formatCellValue(sheet.getRow(row).getCell(col));
System.out.println(data[row][col]);
}
//System.out.println("data within loop" +data[row][col]);
}
//System.out.println("Data from excel " +data);
return data;
}
}
MAIN
package main;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import exceldata.excel_data;
public class main
{
public String baseurl ="http://rumascollection.com.sg/standout";
static WebDriver driver;
@BeforeTest
public void browseropen()
{
System.setProperty("webdriver.chrome.driver", "/Users/rashmimohan/Desktop/Selenium_IDE/chromedriver");
driver = new ChromeDriver();
driver.get(baseurl);
driver.manage().window().maximize();
}
@Test(dataProvider="getdata_fromexcel")
public static void actionmethods(String firstname, String lastname, String email, String telenum, String faxnum, String companyname, String Add1, String Add2, String city, String postalcode, String country, String state, String pwd, String repwd, String size, String qty) throws Throwable
{
System.out.println("*******************");
actions.actions.register(driver);
System.out.println(firstname);
actions.actions.firstname(firstname);
System.out.println("&&&&&");
System.out.println(firstname);
actions.actions.lastname(driver,lastname);
actions.actions.email(driver, email);
actions.actions.telephone(driver, telenum);
actions.actions.fax(driver, faxnum);
actions.actions.companyname(driver, companyname);
actions.actions.Add1(driver, Add1);
actions.actions.Add2(driver, Add2);
actions.actions.City(driver, city);
actions.actions.Postcode(driver, postalcode);
actions.actions.Country(driver, country);
Thread.sleep(1000);
actions.actions.State(driver, state);
actions.actions.password(driver, pwd);
actions.actions.reenter_pwd(driver, repwd);
actions.actions.hit_continue(driver);
actions.actions.catalog(driver);
actions.actions.select_kurti(driver);
actions.actions.select_kurti_size(driver, size);
actions.actions.qty_kurti(driver, qty);
actions.actions.addtocart(driver);
}
@DataProvider
public Object[][] getdata()
{
Object[][] data = new Object[1][16];
data[0][0]="FirstName1";
data[0][1]="LastName1";
data[0][2]="xyz...@gmail.com";
data[0][3]="22222222";
data[0][4]="3333333";
data[0][5]="CompanyName";
data[0][6]="Add1";
data[0][7]="Add2";
data[0][8]="Mangalore";
data[0][9]="575003";
data[0][10]="India";
data[0][11]="Karnataka";
data[0][12]="Password";
data[0][13]="Password";
data[0][14]="S";
data[0][15]="4";
return data;
}
@DataProvider
public Object[][] getdata_fromexcel() throws Throwable
{
Object[][] data1 =excel_data.readdata();
System.out.println("data passed is " +data1);
return data1;
}
}
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fa2588d4-8d8d-41da-bcc1-785346f5f502%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/81fc4f82-0987-466e-9c72-0a3a98877806%40googlegroups.com.
Object[][] data = new Object[1][17];
for( int row=0;row<=1;row++)
{
for( int col=1;col<=16;col++)
{
System.out.println("COL FOR LOOP " +row +" " +col);
data[row][col] = d.formatCellValue(sheet.getRow(row+2).getCell(col));
System.out.println(data[row][col]);
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/ae863da8-f35c-4a1a-84da-1fb17b0a2248%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/b32eb740-7a85-4c29-a8a2-e85c5546077d%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/693D9274-C014-4D2A-9B54-5E4C3745AFA4%40gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAA_T2rGAw%2BwK1hPxQOyGJ6dDmgiKG6bXOQqo0c3-DMhMOG%2Bo0A%40mail.gmail.com.