简体   繁体   中英

Create Executable Jar for Selenium Code

I need to create a Executable Jar file for the Selenium Webdriver Project (TestNG) using Eclipse.

After crawling various website I understand we need to create a Main Class to execute the Test Suite.

I have created a Main Class with below code.

package com.testcases;
import java.util.ArrayList;
import java.util.List;
import org.testng.TestListenerAdapter;
import org.testng.TestNG;
import org.testng.xml.XmlClass;
import org.testng.xml.XmlSuite;
import org.testng.xml.XmlTest;

public class Main {
public static void main(String[] args) {
    // TODO Auto-generated method stub
    TestListenerAdapter tla = new TestListenerAdapter();
    TestNG testng = new TestNG();
     Class[] classes = new Class[]{
             Abc.class,
             PQR.class,
             XYZ.class
             };
     testng.setTestClasses(classes);
     testng.addListener(tla);
     testng.run();
    }
}

When, I have created a runnable Jar using Export->Java->Runnable Jar from Selenium, and after running through jar file using command prompt with below command:

java -jar AbcXyz.jar

Program Execution get into the Infinite loop

Please help for creating such Executable Jar file.

Below are some References: Testng

Did you end your tests with
driver.quit();

This could be the reason

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM