打开浏览器操作
1 /* 2 * 打开浏览器 3 */ 4 public class OpenBrowsers { 5 6 public static void main(String[] args) { 7 // 打开默认路径的 firefox 8 //WebDriver driver = new FirefoxDriver(); 9 10 // 打开指定路径的 firefox 11 //System.setProperty("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); 12 //WebDriver dr = new FirefoxDriver(); 13 14 // 打开指定的 chrome; "E:\\Selenium_New\\JavaForSeleniumLearning\\chromedriver.exe" chromedriver.exe 需从 selenium 下载 15 //System.setProperty("webdriver.chrome.driver", "E:\\Selenium_New\\JavaForSeleniumLearning\\chromedriver.exe"); 16 //WebDriver dr = new ChromeDriver(); 17 18 System.setProperty("webdriver.chrome.bin","C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"); 19 WebDriver driver = new ChromeDriver(); 20 } 21 22 }