1.通过jar包安装

点击Selenium下载 链接 你会看到Selenium Standalone Server的介绍:

The Selenium Server is needed in order to run Remote Selenium WebDriver. Selenium 3.X is no longer capable of running Selenium RC directly, rather it does it through emulation and the WebDriverBackedSelenium interface.

Download version 3.4.0

点击版本号进行下载,下载完成将会得到一个selenium-server-standalone-3.4.0.jar文件。

打开IntelliJ IDEA,导入.jar包。

点击菜单栏 File –> Project Structure(快捷键Ctrl + Alt + Shift + s) ,点击 Project Structure界面左侧 的“Modules” 。在“Dependencies” 标签界面下,点击右边绿色的“+” 号,选择第一个选项“JARs or directories…” ,选择相应的 jar 包,点“OK” ,jar包添加成功。

2.通过Maven安装

关于Maven安装又是另一个话题了。你可以参考其它资料学习在IntelliJ IDEA创建Maven项目。

Maven官网idea & maven helpMaven仓库

打开pom.xml 配置Selenium。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.mvn.demo</groupId>
<artifactId>MyMvnPro</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build> <dependencies> <!-- selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.4.0</version>
</dependency> </dependencies> </project>

虽然,学习Maven需要增加你的学习成本,但如果你需要长期使用Java编程语言,或者想用Java来做更多事情的话,越早使用Maven越好!因为它会让的第三方包管理变得非常简单。

3.Hello Selenium

最后,少不了要写一个简单的Selenium Sample来验证Selenium安装是否成功,打开IntelliJ IDEA 创建一个新类Itest.java

package javaBase;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver; public class Itest {
public static void main(String[] args) { WebDriver driver = new ChromeDriver();
driver.get("http://www.itest.info"); String title = driver.getTitle();
System.out.printf(title); driver.close();
}
}

如果执行报错,请看下一节,Selenium3浏览器驱动。

最新文章

  1. Python 下载 tushare 数据,然后调用 C++ DLL 计算 wMA 存入本地 csv 文件再 python 读取
  2. 【转】WiFi基础知识
  3. Flex 布局2
  4. 黑马----JAVA内部类
  5. Github 新的项目管理模式——Projects
  6. Android WebView 支持H5的定位Js
  7. DNS子域委派配置案例[转载]
  8. [AngularJS] ui-router: named views
  9. PL/SQL Developer不安装客户端连接远程oracle数据库(转)
  10. gdal_merge.py
  11. Week4(9月30日):
  12. Java自定义比较器Comparator
  13. 【ASP.NET】判断访问网站的客户端是PC还是手机
  14. 更多RANK37
  15. iOS日历中给一个事件添加多个提醒
  16. guid.go
  17. RC4加密解密
  18. 照葫芦画瓢之爬虫豆瓣top100
  19. Azure 中的虚拟网络和虚拟机
  20. Cesium添加水面

热门文章

  1. Java注解-注解处理器、servlet3.0|乐字节
  2. LeetCode 783. 二叉搜索树结点最小距离(Minimum Distance Between BST Nodes)
  3. 编程语言、Python介绍及其解释器安装、运行Python解释器的两种方式、变量、内存管理
  4. Vuex入门、同步异步 存取值
  5. jdk8新特性--函数式接口的使用
  6. windows Git Bash 无法运行python文件的解决方法(转)
  7. 火狐浏览器 访问所有HTTPS网站显示连接不安全解决办法
  8. 【转载】在windows上部署使用Redis
  9. 表单送件前的Check(二) (未完)
  10. mvc伪静态