目录
简介
整体思路
Selenium 是一个用于Web应用程序测试的工具。Selenium测试直接运行在浏览器中,就像真正的用户在操作一样。支持的浏览器包括IE(7, 8, 9, 10, 11),Mozilla Firefox,Safari,Google Chrome,Opera等。这个工具的主要功能包括:测试与浏览器的兼容性——测试你的应用程序看是否能够很好得工作在不同浏览器和操作系统之上。测试系统功能——创建回归测试检验软件功能和用户需求。支持自动录制动作和自动生成 .Net、Java、Perl等不同语言的测试脚本。
Selenium包括以下组件:
Selenium IDE:一个Firefox插件,可以录制用户的基本操作,生成测试用例。随后可以运行这些测试用例在浏览器里回放,可将测试用例转换为其他语言的自动化脚本
Selenium Remote Control (RC) :支持多种平台(Windows,Linux,Solaris)和多种浏览器(IE,Firefox,Opera,Safari),可以用多种语言(Java,Ruby,Python,Perl,PHP,C#)编写测试用例。
Selenium Grid :允许Selenium-RC 针对规模庞大的测试案例集或者需要在不同环境中运行的测试案例集进行扩展。
Selenium 2.0兼容Selenium,在Selenium的基础上加入了webdriver。
Selenium 2.0适用于以下浏览器 :
Google Chrome
Internet Explorer 7, 8, 9, 10, 11
Firefox
Safari
Opera
HtmlUnit
phantomjs
Android
iOS
本文档基于Selenium 2.0,环境如下:
操作系统:windows 10 64位
JDK: 1.8
Google Chrome版本:55.0.2883.87 (64-bit)
Firefox版本:54.0.1 (32 位)
IE版本:11
Firefox:https://github.com/mozilla/geckodriver/releases
Chrome:http://chromedriver.storage.googleapis.com/index.html
在firefox中安装了selenium ide插件并生成导出java代码,将java代码导入到idea工具中执行的时候,虽然能打开firefox浏览器,但并没能正常执行测试。最终在chrome下执行成功。在此记录一下整个执行环境涉及到的各个依赖项的版本对应关系。
Selenium ide插件版本(在firefox下录制):selenium_ide-2.9.1-fx.xpi
Firefox版本:54.0.1 (32 位)
Google Chrome版本:55.0.2883.87 (64-bit)
Selenium jar包:3.9.0
下载地址:http://selenium-release.storage.googleapis.com/index.html?path=3.9/
Junit 4
ChromeDriver:2.28
下载地址:http://chromedriver.storage.googleapis.com/index.html?path=2.28/
参考chromedrive和chrome浏览器版本对应关系
地址:https://www.cnblogs.com/-dll-2692663051--html/articles/9306524.html
geckodriver:0.21.0(代码执行报错)
InternetExplorerDriver(和Selenium版本一致,未测试成功,代码执行报错):
下载地址:
http://selenium-release.storage.googleapis.com/index.html?path=3.9/