Se(1)---打开、关闭浏览器
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();
}
}
close方法是关闭浏览器窗口;
quit方法是退出整个webdriver;
也就是说,close以后,wd仍可以进行其他操作;
建议使用quit方法,退出更完整,更安全。