It’s simple !
you have to call the import > import org.openqa.selenium.WebDriver; and others about the browsers, like: import org.openqa.selenium.firefox.FirefoxDriver; (calls Firefox)
After this, in the class Main, declare driver:
WebDriver driver;
and Quit:
Quit quit = new Quit();
So… you have now choose what is the browser and calls the profile and set the configs, like proxy (for this reason you have to create a profile)
public class Main {
public static void main(String[] args) throws Exception {
FirefoxProfile profile = new FirefoxProfile(); // create a profile of Firefox
profile.setPreference(“network.proxy.type”, 0); // Don’t use proxy
driver = new FirefoxDriver(profile); // calls the browser with the configs of the profile
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); // config the timeouts for load a page
driver.get(site); // change site for the url that your driver will open.
quit.tearDown(driver); // quit the driver.
}
}
You have to create the class that close the driver in class Main.
public class Main {
public static class Quit {
public void tearDown(WebDriver driver) {
driver.close();
driver.quit();
}
}
and finish !
This is the first step for create a automation with selenium. Create a driver and open the browser !
Good studies for all, bye !