码迷,mamicode.com
首页 > 其他好文 > 详细

selenium学习笔记(1) 搭建环境

时间:2017-02-16 23:57:39      阅读:329      评论:0      收藏:0      [点我收藏+]

标签:.exe   repo   assert   www   参考   cli   百度   pre   group   

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 }

 

selenium学习笔记(1) 搭建环境

标签:.exe   repo   assert   www   参考   cli   百度   pre   group   

原文地址:http://www.cnblogs.com/snail53/p/6402017.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!