這裡摘錄一些處理所需要的jar包,以及對照關係等。
參考:
selenium-chrome-driver-2.22.0.jar:http://www.java2s.com/Code/Jar/s/Downloadseleniumchromedriver2220jar.htm
selenium-chrome-driver-2.0a4.jar:http://www.java2s.com/Code/Jar/s/Downloadseleniumchromedriver20a4jar.htm
selenium-chrome-driver-2.26.0.jar :http://www.java2s.com/Code/Jar/s/Downloadseleniumchromedriver2260jar.htm
selenium自動化測試資源整理(含所有版本chrome、chromedriver、firefox下載連結):http://blog.csdn.net/huilan_same/article/details/52615123
selenium之 chromedriver與chrome版本對映表(更新至v2.31):http://blog.csdn.net/huilan_same/article/details/51896672
How to Run Webdriver in chrome browser?:http://www.seleniumeasy.com/selenium-tutorials/how-to-run-webdriver-in-chrome-browser
System.setProperty("webdriver.chrome.driver", "pathofchromedriver\\chromedriver.exe");
package com.test; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class TestChromeBrowser { static String driverPath = "path to chrome driver"; public WebDriver driver; @BeforeClass public void setUp() { System.out.println("*******************"); System.out.println("launching chrome browser"); System.setProperty("webdriver.chrome.driver", driverPath+"chromedriver.exe"); driver = new ChromeDriver(); driver.manage().window().maximize(); } @Test public void testGooglePageTitleInIEBrowser() { driver.navigate().to("http://www.google.com"); String strPageTitle = driver.getTitle(); System.out.println("Page title: - "+strPageTitle); Assert.assertTrue(strPageTitle.equalsIgnoreCase("Google"), "Page title doesn't match"); } @AfterClass public void tearDown() { if(driver!=null) { System.out.println("Closing chrome browser"); driver.quit(); } } }
package com.easy; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class ChromeExample { public static String driverPath = "F:/lib/chromedriver/"; public static WebDriver driver; public static void main(String []args) { System.out.println("launching chrome browser"); System.setProperty("webdriver.chrome.driver", driverPath+"chromedriver.exe"); driver = new ChromeDriver(); driver.navigate().to("http://google.com"); } }
待續...