这里摘录一些处理所需要的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"); } }
本文转自 念槐聚 博客园博客,原文链接:http://www.cnblogs.com/haochuang/p/7404729.html,如需转载请自行联系原作者