Selenium Java to launch the Chrome browser
KW.java
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

class KW 
{
    public static void main(String[] args) 
    {
        System.setProperty("webdriver.chrome.driver", "/home/kodingwindow/drivers/chromedriver");
        WebDriver driver = new ChromeDriver();     
        driver.navigate().to("https://kodingwindow.com/testapp/");
        driver.close();
        System.exit(0);
    }   	
}
Selenium Java to launch the Firefox browser
KW.java
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

class KW 
{
    public static void main(String[] args) 
    {
    	System.setProperty("webdriver.gecko.driver", "/home/kodingwindow/drivers/geckodriver");
        WebDriver driver = new FirefoxDriver();
        driver.navigate().to("https://kodingwindow.com/testapp/");
        driver.close();
        System.exit(0);
    }   	
}
Selenium Java to launch the Microsoft Edge browser
KW.java
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;

class KW 
{
    public static void main(String[] args) 
    {
        System.setProperty("webdriver.edge.driver", "/home/kodingwindow/drivers/msedgedriver");
        WebDriver driver = new EdgeDriver();     
        driver.navigate().to("https://kodingwindow.com/testapp/");
        driver.close();
    }       
}
Advertisement