selenium学习笔记(1) 搭建环境
1. 用Eclipse创建maven工程,在pom.xml中添加依赖
1 <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --> 2 <dependency> 3 <groupId>org.seleniumhq.selenium</groupId> 4 <artifactId>selenium-java</artifactId> 5 <version>3.0.1</version> 6 </dependency> 7 <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server --> 8 <dependency> 9 <groupId>org.seleniumhq.selenium</groupId> 10 <artifactId>selenium-server</artifactId> 11 <version>3.0.1</version> 12 </dependency>
*不同版本selenium依赖请参考 https://mvnrepository.com/artifact/org.seleniumhq.selenium
2.下载驱动
https://github.com/mozilla/geckodriver/releases
3.编写测试程序
1 @Test 2 public void test1() { 3 System.setProperty("webdriver.gecko.driver", "E:/selenium/geckodriver.exe"); 4 5 WebDriver driver = new FirefoxDriver(); 6 driver.get("http://www.baidu.com"); 7 8 Assert.assertEquals("百度一下,你就知道", driver.getTitle()); 9 driver.quit(); 10 }
这世界真的也许有太多的你不如意,可你的生活虽然坎坎坷坷仍在继续,希望就住在你的心底,愿你勤勤恳恳善待别人关心自己美好的日子等你