Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» FlexMonkium Download Not available under Gorillalogic site
Thu Dec 08, 2016 5:40 pm by bhanu.praveen

» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Need Selenium Webdriver + Excel sheet examples

View previous topic View next topic Go down

Need Selenium Webdriver + Excel sheet examples

Post by sreekumar on Tue Mar 06, 2012 9:06 pm

Hi All

Please give me some examples for read/write operations from excel sheet using selenium webdriver.

I tried a few examples but getting ArrayIndexOutofBound exception getting

import jxl.Sheet;
import jxl.Workbook;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import java.io.FileInputStream;
import java.io.IOException;

import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;


public class TestData{

WebDriver driver = new ChromeDriver();

public void Login() throws InterruptedException, BiffException, IOException
{
FileInputStream fi=new FileInputStream("D:\\sreeworkspace\\sree.xls");
Workbook workbook = Workbook.getWorkbook(fi);

Sheet sheet = workbook.getSheet("Login");
String s=sheet.getCell(2,2).getContents();
System.out.println(s);

driver.findElement(By.id("gbqfq")).sendKeys(s);
driver.findElement(By.name("btnK")).click();


}

public static void main(String[] args) throws InterruptedException, BiffException, IOException {

System.setProperty("webdriver.chrome.driver", "D:/sreekumar/Tutorial/Selenium/chromedriver_win_18.0.995.0/chromedriver.exe");

//Pausing here seems to make it work better, so...


TestData login = new TestData();
login.driver.get("https://www.google.com");
login.Login();
}
}

sreekumar
Active particpant
Active particpant

Posts : 16
Join date : 2011-12-27
Age : 31
Location : Hyderabad

Back to top Go down

Re: Need Selenium Webdriver + Excel sheet examples

Post by Arahant on Wed Mar 07, 2012 12:32 pm

Hi ,
I gone through your code.you are trying to read excel spread sheet.For this try to use below code might be helpful for you.


@DataProvider (name = "DP1")
public Object[][] readdata() throws Exception{
Object[][] retObjArr=gettableArry("test\\Resources\\Data\\data1.xls","DataPool","ImdbTestData1");


return(retObjArr);
}

@Test (dataProvider = "DP1")
public void testdataprovider(String Type,String Os,String Version,String Language) throws Exception{
(Here number of string and name should be same with your excel sheet column)
System.out.println("Type is ===>" Type);
System.out.println("os is ===>" Os);
System.out.println("version is ===>" Version);
System.out.println("language is ===>" Language);

}


private Object[][] gettableArry(String xslsheet, String sheetname, String tablename) throws Exception {
String[][] tabArray=null;

Workbook wb = Workbook.getWorkbook(new File(xslsheet));
Sheet st = wb.getSheet(sheetname);
int startRow,startCol, endRow, endCol,ci,cj;

Cell tableStart=st.findCell(tablename);
startRow=tableStart.getRow();
System.out.println("Initiated rows to sheet ======>" startRow);
startCol=tableStart.getColumn();
Cell tableEnd = st.findCell(tablename, startCol 1,startRow 1, 100, 64000, false);
endRow=tableEnd.getRow();
endCol=tableEnd.getColumn();
tabArray=new String[endRow-startRow-1][endCol-startCol-1];
ci=0;
for (int i=startRow 1;i

Arahant
Active particpant
Active particpant

Posts : 23
Join date : 2012-02-29

Back to top Go down

Re: Need Selenium Webdriver + Excel sheet examples

Post by sreekumar on Thu Mar 08, 2012 8:16 pm

Thank you so much , the above example works fine.....

sreekumar
Active particpant
Active particpant

Posts : 16
Join date : 2011-12-27
Age : 31
Location : Hyderabad

Back to top Go down

Re: Need Selenium Webdriver + Excel sheet examples

Post by ashish_techie on Mon May 14, 2012 11:33 pm

Use the POI API.

Regards
Ashish
For selenium videos visit:
http://qtpselenium.com/selenium-tutorial

ashish_techie
Amateur
Amateur

Posts : 73
Join date : 2011-08-09

Back to top Go down

Re: Need Selenium Webdriver + Excel sheet examples

Post by Sponsored content Today at 6:05 am


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum