Is it possible to make Selenium WebDriver executable file in java? I have written code in java for data driven testing using Selenium WebDriver. I want to make it executable file so that outside eclipse one can execute it.
package pkg;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class LogingS {
private WebDriver driver;
private String baseUrl;
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "http://www.example.com/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testLogingS() throws Exception {
driver.get(baseUrl);
System.out.println("The current Url: " + driver.getCurrentUrl());
driver.findElement(By.id("id_email")).clear();
driver.findElement(By.id("id_email")).sendKeys("com");
Thread.sleep(1000);
driver.findElement(By.id("id_password")).clear();
driver.findElement(By.id("id_password")).sendKeys("123");
Thread.sleep(1000);
System.out.println("The current Url: " + driver.getCurrentUrl());
driver.findElement(By.id("btn_login")).submit();
Thread.sleep(5000);
System.out.println("The current Url: " + driver.getCurrentUrl());
}
@After
public void tearDown() throws Exception {
}
}
To create a new JAR file in the workbench:
Either from the context menu or from the menu bar's File menu, select Export.
Expand the Java node and select JAR file. Click Next.
In the JAR File Specification page, select the resources that you want to export in the Select the resources to export field.
In the Select the export destination field, either type or click Browse to select a location for the JAR file and Finish
Open CMD, move upto your .jar
Call jar file using following command :- java -jar xxx.jar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With