由于前期有个项目已经有不止4个版本,针对这些版本的测试如果纯人工测试成本较大,而且后续也会有更多个新的升级版出现,所以考虑采用自动化进行测试。
需要用到的插件(必备辅助工具)及selenium相关的部分jar包的下载地址如下:
selenimu IDE及相关jar包下载地址:
http://seleniumhq.org/download/(seleniumIDE其他版本下载地址:http://release.seleniumhq.org/selenium-ide/)
firebug下载地址:
https://addons.mozilla.org/zh-CN/firefox/addon/firebug/(或者http://getfirebug.com/releases/firebug/)
firepath(需要firebug才能正常工作)下载地址:
https://addons.mozilla.org/zh-CN/firefox/addon/firepath/
firebug为firefox的一个插件,可以用来定位页面元素的html标签位置,特别是id是动态的时候。
With FirePath you can:
*
Edit XPath expressions, CSS3 selectors and JQuery selectors (Sizzle selector
engine) with auto completion for XPath (using TAB or up and down arrows).
* Evaluate the expression/selector on any
HTML or XML documents.
* Display the result of evaluations in a
Firebug-like DOM tree.
* Highlight the results directly on the
document displayed by Firefox (works only with HTML documents).
* Generate an XPath expression or a CSS
selector for an element by right clicking on it and selecting "Inspect in
FirePath" in the context menu.
* Define the evaluation context (parent) of
an expression/selector.
* Choose the document in which to evaluate
the expression/selector (only applicable for HTML documents with frames or
iframes).
FirePath 0.9.7 requires Firefox
3.5 to 6.0 and Firebug 1.4 to 1.8.*[注意]-网上说0.9.7的firepath支持的firebug的最高版本是1.8.*,但是我使用1.9.2的firebug也还是支持的,使用过程中也没有遇到其他的问题。
Note that the XPath auto completion does
not work with Firebug 1.6 and higher
由于firebug、firefox、selenium IDE均为firefox的插件,故其安装可以直接通过将下载好的离线插件文件拖动到firefox完成安装,如果没有离线的插件文件也可以直接通过firefox的“附加组件管理器”进行在线下载并完成安装。
本人都是通过下载离线插件文件进行安装的,下载的版本见下一章节。
实施可用环境如下(亲测可用):
firefox5.0.1+firebug1.8.3/1.9.2+firepath0.9.7.1.1-signed+selenium
IDE 0.25.1-signed。安装后通过“工具”->“附加组件”打开显示下图所示内容说明前期的准备工作已经做好:
其他的需要用到的jar包有(暂时还没有用到):
说明:在使用selenium
IDE调试脚本的时候就会用到firebug和firepath这2个插件,用的最多的就是使用firebug定位页面元素,使用firepath获取xpath路径(原生态的firebug不支持按xpath查找元素,在无法使用id、name定位元素时可以使用firepath获取xpath路径)。
优秀博文推荐:http://blog.sina.com.cn/s/blog_68cb48770100v9c7.html(seleniumIDE+firebug+seleniumRC)