How to read data from excel using Selenium

We have know that Selenium is using for Web application testing and Browser testing.

Today we are learning how to read data from excel using Selenium.In order to perform this action we need to download third party APIs for excel to load into Selenium.For this we are using jxl.jar file for Excel operations in Selenium.

Please download jxl jar from this download jar

Steps to create script.

1.Create project
2.Create Package
3.Create Class
4.Associate library files to project
5.Create the Excel sheet with data,for example i am using Gmail login.Please fine the below

6.Start the Selenium Server
7.Create the below script

package com.Gmail.Login;

import static org.junit.Assert.*;

import jxl.Sheet;
import jxl.Workbook;
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;

@SuppressWarnings({ "unused", "deprecation" })
public class Gmaillogins extends SeleneseTestCase{

   public void setUp() throws Exception {
       SeleniumServer ss=new SeleniumServer();
       selenium=new DefaultSelenium("localhost",4444,"firefox", "");

   public void tearDown() throws Exception {

   public void test() throws BiffException, IOException, InterruptedException {"/");
       FileInputStream fis=new FileInputStream("D:\\2014\\Java_Applications\\gmail_login.xls");
       Workbook wb=Workbook.getWorkbook(fis);
       Sheet s=wb.getSheet(0);


8.Save the script

9.Run the script

No comments:

Post a Comment