Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package twselenium; import java.util.concurrent.TimeUnit; import org.openqa.selenium.WebDriver; import java.io.File; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.ie.InternetExplorerDriver; import org.openqa.selenium.phantomjs.PhantomJSDriver; public class BrowserThread extends Thread { static WebDriver driver; private String baseUrl; private String browsertype; public BrowserThread(String name, String browsertype) { super(name); this.browsertype = browsertype; } // set up method to initialize driver object public void setUp(String browsertype) throws Exception { if (browsertype.contains("Chrome")) { System.setProperty("webdriver.chrome.driver", "res\\chromedriver.exe"); driver = new ChromeDriver(); } else if (browsertype.contains("PhantomJS")) { driver = new PhantomJSDriver(); System.setProperty("phantomjs.binary.path", "res\\phantomjs.exe"); } else if (browsertype.contains("PhantomJS Linux")) { driver = new PhantomJSDriver(); System.setProperty("phantomjs.binary.path", "res/phantomjs.exe"); } baseUrl = "https://www.google.com/"; driver.get(baseUrl); } }