Saturday, 7 October 2017

CSV Comparision


Here is the explanatory video and following method :




public class compareCSV {

/**
* @param args
* @throws IOException
         * @author : Aman Saraf Jain
*/
public static void main(String[] args) throws IOException {

HashSet<String> f1 = new HashSet<String>(FileUtils.readLines(new File("C:\\Users\\Aman\\Desktop\\demo\\1.csv")));
HashSet<String> f2 = new HashSet<String>(FileUtils.readLines(new File("C:\\Users\\Aman\\Desktop\\demo\\2.csv")));
f1.removeAll(f2); // f1 now contains only the lines which are not in f2

System.out.println(f1.toString());

}

}

Saturday, 22 April 2017

Use of Log4j in your Java Program


Download Sample Project from here.

Steps to use log4j :

1.) Download log4j dependency.(included in sample project)
2.) Download log4j.properties (included in sample project)

Create Java Program:

package com.asj;

import org.apache.log4j.Logger;

public class LoggerDemo {
/**
* @created by Aman
*/
public static Logger logger = Logger.getLogger(LoggerDemo.class);

public static void main(String[] args) {
logger.info("Hello!! you are in info log");

logger.warn("Hello!! you are in warn log");

logger.error("Hello!! you are in error log");

logger.debug("Hello!! you are in debug log");
}

}

Monday, 2 February 2015

Extract Hbase table through Mapreduce and print table data in to hdfs file (Sample program)

Create Hbase Table


create 'test1', 'cf1'
put 'test1', '20130101#1', 'cf1:sales', '100'
put 'test1', '20130101#2', 'cf1:sales', '110'
put 'test1', '20130102#1', 'cf1:sales', '200'
put 'test1', '20130102#2', 'cf1:sales', '210'

Create Java project with 3 files and include all Hbase required Jars:-

testDriver.java :

package TableDataHdfsFile;

import java.io.File;
import java.io.IOException;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.commons.io.
FileUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;



public class testDriver
{   
      static String FilePath = "/home/admin/Test/mysummary";
      public static void main(String[] args) throws Exception
      {
          File file = new File(FilePath);
          if (file.exists())
          {
              FileUtils.cleanDirectory(file); //clean out directory (this is optional -- but good know)
              FileUtils.forceDelete(file); //delete directory
          }

        FileSystem fs = FileSystem.get(config);
          if (fs.exists( new Path(FilePath)))
          {
              fs.delete(new Path(FilePath), true); // delete file, true for recursive
          }
          Configuration config = HBaseConfiguration.create();
          Job job = Job.getInstance(config);
          job.setJobName("ExampleSummaryToFile");
          job.setJarByClass(testDriver.class);     // class that contains mapper and reducer

          Scan scan = new Scan();
          scan.setCaching(500);        // 1 is the default in Scan, which will be bad for MapReduce jobs
          scan.setCacheBlocks(false);  // don't set to true for MR jobs
          // set other scan attrs

          TableMapReduceUtil.initTableMapperJob(
                  "test1",        // input table
                  scan,               // Scan instance to control CF and attribute selection
                  testMapper.class,     // mapper class
                  Text.class,         // mapper output key
                  IntWritable.class,  // mapper output value
                  job);
          System.out.println(job.getJobName());
          job.setReducerClass(testReducer.class);    // reducer class
          job.setNumReduceTasks(1);    // at least one, adjust as required
         
        

          FileOutputFormat.setOutputPath(job, new Path(FilePath));  // adjust directories as required

          boolean b = job.waitForCompletion(true);
          if (!b) {
                  throw new IOException("error with job!");
          }
      }
}



testMapper.java :-

package TableDataHdfsFile;

import java.io.IOException;

import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.mapreduce.TableMapper;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;


public  class testMapper extends TableMapper<Text, IntWritable>  {
    public static final byte[] CF = "cf".getBytes();

    private final IntWritable ONE = new IntWritable(1);
       private Text text = new Text();

       public void map(ImmutableBytesWritable row, Result value, Context context) throws IOException, InterruptedException {
          // byte[] bSales = columns.getValue(Bytes.toBytes("cf1"), Bytes.toBytes("sales"));
            String val = new String(value.getValue(Bytes.toBytes("cf1"), Bytes.toBytes("sales")));
            text.set(val);     // we can only emit Writables...
            context.write(text, ONE);
       }
}

testReducer.java :-

package TableDataHdfsFile;

import java.io.IOException;
import org.apache.hadoop.io.
IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;



public class testReducer extends Reducer<Text, IntWritable, Text, IntWritable>  {

    public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
            int i = 0;
            for (IntWritable val : values) {
                    i += val.get();
            }
            context.write(key, new IntWritable(i));
    }
}

//Create a jar and run basic program given above , we may parametrize this program  also.

// Done

Saturday, 8 November 2014

Invoke Maven Project by - Jenkins !!



How to invoke maven project through Jenkins steps are below :-

1. Download and install jenkins.

2. Run jenkins.war by following command :-

java -jar jenkins.war --httpPort=9090
If you want to use https use the following command:
java -jar jenkins.war --httpsPort=9090

3. Create Jenkins Job:-

Create TestMaven Job


before creating job ensure that you set jdk path in jenkins configuration.


4. Set your POM.xml file path and build jenkins job :-









Done :)

For Creating Maven Project :- Link





Friday, 7 November 2014

How To Create Maven Project !!


Here is the way to create way to create maven project :-

1.) Install Maven in your latest eclipse.

2.) Create Maven Project.

3.) Create Below Java file in package com under src/main/java -

package com;
import javax.swing.JOptionPane;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class TestClass {
   
     public static void main(String[] args) throws InterruptedException {
            // Create a new instance of the firefox driver
            // Notice that the remainder of the code relies on the interface,
            // not the implementation.
            WebDriver driver = new FirefoxDriver();

            // And now use this to visit Google
            driver.get("http://www.google.com");

            // Find the text input element by its name
            WebElement element = driver.findElement(By.name("q"));

            // Enter something to search for
            element.sendKeys("cheese!");

            // Now submit the form. WebDriver will find the form for us from the element
            element.submit();

            Thread.sleep(5000);
            // Check the title of the page
            JOptionPane.showMessageDialog(null, "Page title is: " + driver.getTitle());
                
            driver.quit();
        }

}

4.)  Edit your pom.xml

Here is edited  pom.xml :-

<project
    xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>kepler_maven</groupId>
    <artifactId>kepler_maven</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.44.0</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.1.1</version>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>com.TestClass</mainClass>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

5.) Run pom.xml as Maven Install

6.) Here is the complete zipped project Maven Sample Project

Done !!





Thursday, 16 October 2014

Automatic File Download Selenium Java



Below code snippet for Firefox :-

Automatic File Download Selenium Java

---------------------------------------------------START-----------------------------------------------------

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import atu.utils.windows.handler.exceptions.WindowsHandlerException;


public class autoDownLoad {

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

 FirefoxProfile profile = new FirefoxProfile();
 String path="d:\\downloads123";
 profile.setPreference("browser.download.folderList", 2);
 profile.setPreference("browser.download.dir", path);
 profile.setPreference("browser.download.manager.alertOnEXEOpen", false);
 profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/msword,application/csv,text/csv,image/png ,image/jpeg, application/pdf, text/html,text/plain,application/octet-stream");
 profile.setPreference("browser.download.manager.showWhenStarting", false);
 profile.setPreference("browser.download.manager.focusWhenStarting", false); 
 profile.setPreference("browser.download.useDownloadDir", true);
 profile.setPreference("browser.helperApps.alwaysAsk.force", false);
 profile.setPreference("browser.download.manager.alertOnEXEOpen", false);
 profile.setPreference("browser.download.manager.closeWhenDone", false);
 profile.setPreference("browser.download.manager.showAlertOnComplete", false);
 profile.setPreference("browser.download.manager.useWindow", false);
 profile.setPreference("browser.download.manager.showWhenStarting",false);
 profile.setPreference("services.sync.prefs.sync.browser.download.manager.showWhenStarting", false);
 profile.setPreference("pdfjs.disabled", true);
 WebDriver driver = new FirefoxDriver(profile);
driver.get(YOUR URL);
}

}


More Type--- > MIME TYPES

-----------------------------------------------------END------------------------------------------------------

Monday, 22 September 2014

Loggers In Ruby



require 'logger'

logger = Logger.new($stdout)
logger.warn("This is a warning")
logger.info("This is an info")


//$stdout redirects all logs to console. If you want to redirect all this to a file then //need to initialize $stdout='/home/Aman_Test/log.txt', 'w'

Monday, 1 September 2014

Selenium WebDriver and AutoIT

It is often possible in this web world that we get to work with objects which is either out of box,flash or webpages that are added with extra layer of security like a single sign-on for example windows credentials


Also another example is if one works with Microsoft technologies or Oracle CRM Web Applications which are only compatible with IE browsers there LOV(List of Values) popup , not to forget the modal popup

In the above situations it's hard to achieve or progress with automation with Selenium RC/Selenium WebDriver 

Hence the simplest and fairly easy option is AutoIT

What is AutoIt ?

AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying "runtimes" required!

Let's get started with having AutoIt installed on your local box

Download latest version of AutoIt from the official release page here 

It's better you download AutoIt Full Installation which will help you in scripting & compiling as well

Once installation is completed you should see the application being installed in your All Programs or which ever location you have installed

Now, let's get started - What is that we are trying to automate or use AutoIt for

Given this Scenario : Of Logging in the windows Authentication to your webapplication

Just like the below screen shot



Windows login modal as popped out by Windows OS :

Here is how the AutoIt Script should look


WinWaitActive("Connect to yourservername","","60")
  If WinExists("Connect to yourservername") Then 
     ControlSend("Connect to yourservername","", "[CLASS:Edit; INSTANCE:2]","DomainName\username")
     ControlSend("Connect to yourservername","", "[CLASS:Edit; INSTANCE:3]","Password") 
     ControlClick("Connect to yourservername","","[CLASS:Button; INSTANCE:3,button[,clicks[,153[,223]]]]") 
EndIf 



Once you have the above script compiled - You are all ready to use them in your webDriver / selenium RC script
 so here is example for JAVA

So here's the code that goes in your webDriver script

        @BeforeClass 
        public static void setUp()
        {
              System.setProperty("webdriver.ie.driver", "C:\\Eclipse\\Selenium\\IEDriverServer.exe");
              driver = new InternetExplorerDriver();
              driver.get("your url");
              try {
                        Runtime.getRuntime().exec("C:\\Eclipse\\Selenium\\Autentication.exe");
                  } catch (IOException e) 
                  {
                              e.printStackTrace();
                   }
        }

You are all set now : both the code snippets together should help in working on Windows Authentication
 Courtsey : automationwithseleniumblog

Sunday, 31 August 2014

How to use Logger in our JAVA simple projects / Programs


Simple way to use logger in our project

Steps to use :

1.) Download log4j jars link is lo4j.jars
2.) Try sample project in Eclipse or run normally link to download is Sample Logger Project


Sample program looks like :-

package TestLogger;
import java.io.IOException;
import Logger.LoggerInstance;

public class SampleClass {

public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
LoggerInstance loggerObj = new LoggerInstance();
System.out.println("Hello World");
LoggerInstance.logger.info("Hello World");
}
}

To use these Logger Instance we need to define separate class that you can find in dummy project or refer below class :-

package Logger;

import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.log4j.FileAppender;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;

public class LoggerInstance {

public static Logger logger;
File directory = new File ("");
String absolutepath = directory.getAbsolutePath();
//This is to get location for creating log file. This value is comming from build.xml
String str_logFilePath = absolutepath+File.separator+"log";


public LoggerInstance() throws IOException
{
DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
Date date = new Date();
System.out.println(date);
String current_dateTime = dateFormat.format(date);
System.out.println(current_dateTime);
current_dateTime = current_dateTime.replace("-", "_");
current_dateTime = current_dateTime.replace(" ", "_") ;
current_dateTime = current_dateTime.replace(":", "_") ;

File f1 = new File(str_logFilePath) ;
if(!f1.exists()){
f1.mkdir();
}
//System.out.println("00 " + str_logFilePath);

String str_logFilePath1 = str_logFilePath+File.separator+"LogFile_created_by_ASJ_"+current_dateTime+".log";
//System.out.println("11 " + str_logFilePath1);

File f2 =  new File(str_logFilePath1);
f2.createNewFile();


if(logger==null)
{
try{
logger = Logger.getLogger("ASJ");
FileAppender apndr = new FileAppender(new PatternLayout("%p %t %c - %m%n"),str_logFilePath1,true);
//apndr.setAppend(true);
logger.addAppender(apndr);
}
catch(Exception e)
{
System.out.println("Log file is not initialized");
}
}
}

}


So it is easy to run :-)

Tuesday, 29 April 2014

Thursday, 24 April 2014

Email Verification through Java

 We can verify Emails sample example is given for gmail :--
just add this jar file to your program :- Mail.jar

package Mail_ver;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import javax.mail.search.SubjectTerm;

public class mail_content_verification {
public static void main(String args[]) throws Exception {
 Properties props = System.getProperties();
       props.setProperty("mail.store.protocol", "imaps");

           Session session = Session.getDefaultInstance(props, null);
           Store store = session.getStore("imaps");
           store.connect("imap.gmail.com", "UserName",
                   "Password");

           Folder folder = store.getFolder("INBOX");
           folder.open(Folder.READ_WRITE);

           System.out.println("Total Message:" + folder.getMessageCount());
           System.out.println("Unread Message:"
                   + folder.getUnreadMessageCount());
Folder inbox = store.getFolder("Inbox");
inbox.open(Folder.READ_ONLY);
Message messages[] = inbox.getMessages();
for(Message message:messages) {
System.out.println(message);
}
   }
}

Tuesday, 4 February 2014

Use of Robot Class (This sample code will show the use of Robot class to handle the keyboard events. If you run this code and open a notepad then this code will write hi budy in the notepad)

Java.awt.Robot class is used to take the control of mouse and keyboard. Once you get the control, you can do any type of operation related to mouse and keyboard through your java code. This class is used generally for test automation. 

As we can handle windows based Modal dialog and file dialogs.

Sample Code :-

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;

public class RobotExp {

public static void main(String[] args) {

try {

Robot robot = new Robot();
// Creates the delay of 8 sec so that you can open notepad before or we can call notepad from java


// Robot start writing
robot.delay(5000);
robot.keyPress(KeyEvent.VK_H);
robot.keyPress(KeyEvent.VK_I);
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyPress(KeyEvent.VK_B);
robot.keyPress(KeyEvent.VK_U);
robot.keyPress(KeyEvent.VK_D);
robot.keyPress(KeyEvent.VK_Y);

} catch (AWTException e) {
e.printStackTrace();
}
}


--------------------------------------------------------------------------------------------------------------------------

Send Ctrl + Z

robot.keyPress(KeyEvent.VK_CONTROL)
robot.keyPress(KeyEvent.VK_Z)
// CTRL+Z is now pressed (receiving application should see a "key down" event.)
robot.keyRelease(KeyEvent.VK_Z)
robot.keyRelease(KeyEvent.VK_CONTROL)
// CTRL+Z is now released (receiving application should now see a "key up" 
event - as well as a "key pressed" event).
------------------------------------------------------------------------------------
Use of TAB
    robot.keyPress(KeyEvent.VK_TAB);
    robot.delay(100);
    robot.keyRelease(KeyEvent.VK_TAB);

BY Using all above methods and robot class we can authenticate Windows login modal.

Monday, 6 January 2014

Image Comparision in Java(Can use with Selenium)

Sample Prog:-

package ASJ_IMG_CMP;

import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.PixelGrabber;
import java.io.File;

class Image_CMP{
public static String imageComparison() {
System.out.println("Executing imageComparison");

try {

String file1 = "C:\\Documents and Settings\\amanjain\\Desktop\\1.PNG";
String file2 = "C:\\Documents and Settings\\amanjain\\Desktop\\2.PNG";

Image img1 = Toolkit.getDefaultToolkit().getImage(file1);
Image img2 = Toolkit.getDefaultToolkit().getImage(file2);

try {

PixelGrabber grab1 = new PixelGrabber(img1, 0, 0, -1, -1,false);
PixelGrabber grab2 = new PixelGrabber(img2, 0, 0, -1, -1,false);

int[] data1 = null;

if (grab1.grabPixels()) {
int width = grab1.getWidth();
int height = grab1.getHeight();
data1 = new int[width * height];
data1 = (int[]) grab1.getPixels();
}

int[] data2 = null;

if (grab2.grabPixels()) {
int width = grab2.getWidth();
int height = grab2.getHeight();
data2 = new int[width * height];
data2 = (int[]) grab2.getPixels();
}

System.out.println("Pixels equal: "
+ java.util.Arrays.equals(data1, data2));

if(java.util.Arrays.equals(data1, data2)==true){
    System.out.println("Both Images are Same");
}
else
    System.out.println("Both images are diffrent");

} catch (InterruptedException e1) {
e1.printStackTrace();
}
return "Pass";
} catch (Throwable t) {
// report error
return "Fail - " + t.getMessage();
}

}
public static void main(String args[]){
    imageComparison();
}
}

Saturday, 14 December 2013

Conversion Html tc to excel

Convert Selenium IDE  HTML TC in to HTML format 


so we can run excel in Keyword driven Framework..

Src Given Below jst Add apache poi jars to ur Eclipse Project.

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

import javax.script.*;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ExportToExcel {

/**
 * @param args
 * @throws IOException 
 */
int Stepno=0;
String str="";
String temp="";
static String Outputfile="";
List <String> Action=new LinkedList<String>();
List <String> Locator=new LinkedList<String>();
List <String> Value=new LinkedList<String>();
int i=4;
public void Export(String path) throws ScriptException, IOException
{
/*ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("javascript");*/
File f=new File(path);
 BufferedReader br = new BufferedReader(new FileReader(f));
    try {
        StringBuilder sb = new StringBuilder();
        String line = br.readLine();

        while (line != null) {
            sb.append(line);
            sb.append('\n');
            line = br.readLine();
        }
        str += sb.toString();
        
        //str="<td>aman</td>";
        String a[]=str.split("<td>");
        for (i=1;i<a.length;i=i+3)
        {
         temp=a[i].substring(0, a[i].indexOf('<'));
         Action.add(temp);
        } 
        for (i=2;i<a.length;i=i+3)
        {
         temp=a[i].substring(0, a[i].indexOf('<'));
         Locator.add(temp);
        } 
        for (i=3;i<a.length;i=i+3)
        {
         temp=a[i].substring(0, a[i].indexOf('<'));
         Value.add(temp);
        }      
        
      System.out.println("Action List is : "+Action);
      System.out.println("Locator List is : "+Locator);
      System.out.println("Value List is : "+Value);
        
    } finally {
        br.close();
    }  
     }
public void writetoExcel(String excelFileName) throws InvalidFormatException, IOException
{
//String excelFileName = "";//name of excel file
 
String sheetName = "Sheet1";//name of sheet
 
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet(sheetName) ;
XSSFRow r1 = sheet.createRow(0);
XSSFCell Srnocell = r1.createCell(0);
Srnocell.setCellValue("Srno");
XSSFCell actioncell = r1.createCell(1);
actioncell.setCellValue("Action");
XSSFCell loccell = r1.createCell(2);
loccell.setCellValue("Locator");
XSSFCell valuecell = r1.createCell(3);
valuecell.setCellValue("Value");
for (int r=1;r <4; r++ )
{
XSSFRow row = sheet.createRow(r);
Stepno++; 
//iterating c number of columns
XSSFCell cell = row.createCell(0);
cell.setCellValue(Stepno);
    XSSFCell cell1 = row.createCell(1);
cell1.setCellValue(Action.get(r-1)); 
System.out.println(Action.get(r-1));
 
    XSSFCell cell2 = row.createCell(2);
cell2.setCellValue(Locator.get(r-1)); 
System.out.println(Locator.get(r-1));
    XSSFCell cell3 = row.createCell(3);
cell3.setCellValue(Value.get(r-1));
System.out.println(Value.get(r-1));
}
 
FileOutputStream fileOut = new FileOutputStream(excelFileName);
 
//write this workbook to an Outputstream.
wb.write(fileOut);
fileOut.flush();
fileOut.close();
System.out.println("Your excel file has been generated!");
JOptionPane.showMessageDialog(null,excelFileName+" is generated successfully");
}
public static void main(String[] args) throws ScriptException, IOException, InvalidFormatException {
// TODO Auto-generated method stub
ExportToExcel e=new ExportToExcel();
JFileChooser chooser=new  JFileChooser();
        int returnVal = chooser.showOpenDialog(null);
        
        if(returnVal == JFileChooser.APPROVE_OPTION) 
        {
        //File f = chooser.getSelectedFile();
        String filename=chooser.getSelectedFile().getPath();
        if (filename.endsWith(".html")){
         Outputfile=filename.replace(".html", ".xlsx");
         e.Export(filename);
e.writetoExcel(Outputfile);
        }
        else
        {
         JOptionPane.showMessageDialog(null, "Pls select only Recorded HTML file");
         //System.exit(0);
        }
        
    }

}}