I am trying to convert my Selenium code(Selenium with TestNG) to the Jar (Executable Jar file) which can be double clicked to execute. I did some research and found the way to do it. (Executable Jar File Research - 1 & Executable Jar File Research - 2)
I tried the ways but not able to do so. Also, I would point out that my Selenium code does not have main method.
Error: I am not getting any Launch configuration while converting it to Jar.
Can some tell me where am i going wrong in this?
EDITED CODE:
package com.gs.TestSuiteBase;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.gs.Access.*;
import com.gs.Global.Constant;
import com.gs.Global.ExcelUtility;
import com.gs.Search.Search;
import com.gs.TestDataLibrary.*;
import com.gs.TestSuiteLibrary.*;
import com.gs.TransactionsCustomer.CustomerBase;
import transactions.*;
public class TestSuiteBase {
//Driver Declaration
public static WebDriver driver;
//Page Object Declaration - Functions
public Login objLogin = new Login();
public Search objSearch = new Search();
public Customer objCustomer = new Customer();
public Logout objLogout = new Logout();
//Page object Declaration - Data Library
public LoginDataLibrary objLoginData = new LoginDataLibrary();
public CustomerDataLibrary objCustomerData = new CustomerDataLibrary();
//Page Object Declaration - Suite Library
public TestSuiteLibrary objTestSuite = new TestSuiteLibrary();
public TransactionsCustomer objCustomerTestCase = new TransactionsCustomer();
public CustomerBase objCustomerBase = new CustomerBase();
@BeforeClass
public static void main() {
System.out.println("*******************");
System.out.println("launching IE browser");
System.setProperty("webdriver.ie.driver", Constant.driverAccess);
driver = new InternetExplorerDriver();
driver.manage().window().maximize();
}
@Test (priority = 1)
public void getPageTitle() {
driver.navigate().to(Constant.gavasevaUrl);
String strPageTitle = driver.getTitle();
System.out.println("Page title: - "+strPageTitle);
Assert.assertTrue(strPageTitle.equalsIgnoreCase("Ganaseva Login"), "Page title doesn't match");
}
@Test (priority = 2)
public void login() throws Exception {
ExcelUtility.setExcelFile(Constant.testDataFileAccess,"LoginData");
objLoginData.setLoginDataLibraryCompleteData();
objLogin.performLogin(driver, objLoginData.getLoginName(), objLoginData.getPassword(), objLoginData.getCaptcha());
objLogin.assertLogin(driver);
objLogin.assertUserName(driver, objLoginData.getuserFullName());
}
@Test (priority = 3)
public void createCustomer() throws Exception {
ExcelUtility.setExcelFile(Constant.testSuiteFileAccess,"TestSuiteList");
objTestSuite.setTestSuiteLibrary(1);
System.out.println("Suite: " + objTestSuite.getSuiteNo() + " " + objTestSuite.getSuiteName());
if(objTestSuite.getSuiteToRun().equals("YES")) {
//Call Customer Base to execute Customer Test Cases;
objCustomerBase.customerTestCasesExection(driver);
}
else {
System.out.println("Skipped");
//Set Execution details in "TestSuite.xlsx" file;
ExcelUtility.setCellData(Constant.testSuiteFileAccess, "Skipped", 1, 9);
}
}
@Test (priority = 4)
public void logout() {
objLogout.performLogout(driver);
}
@AfterClass
public void tearDown() {
if(driver!=null) {
System.out.println("Closing IE browser");
driver.quit();
}
}
}
t had main method in my Script as Testing doen
t need. But I made change to my script and added a main method to it. Still, I am not able to get anything in the Launch Config. dropdown. I have added my edited code in original post.