Se (1)-Open and close browsers
package test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
public class OpenCloseBrowser {
@Test
public void test() throws InterruptedException{
//Firefox
/*System.setProperty("webdriver.firefox.bin", "D:/Firefox/firefox.exe");
WebDriver wd = new FirefoxDriver();*/
//chrome
System.setProperty("webdriver.chrome.driver", "D:/01 Learn WebDriver/chromedriver.exe");
WebDriver wd = new ChromeDriver();
Thread.sleep(5000);
//ie
/*System.setProperty("webdriver.ie.driver", "D:/01 Learn WebDriver/IEDriverServer.exe");
WebDriver wd = new InternetExplorerDriver();*/
//wd.close();
wd.quit();
}
}
The close method closes the browser window;
The quit method is to quit the entire webdriver;
In other words, after close, wd can still perform other operations;
It is recommended to use the quit method, which is more complete and safer.