软件测试技术第二次实验报告
软件测试技术第二次实验报告
一、需求分析(描述具体需求)
- Install Selenium with Eclipse.
- Install Firefox and SeleniumIDE plugin.
- Try to record and export scripts using SeleniumIDE.
- Please complete the following task using Selenium: “软件测试名单.xlsx” contains information about the students, and http://121.193.130.195:8800 can view someone’s information after logging in (student id as username, the last 6 digits of student id as password). Please check each record in the excel to make sure that each student’s information is consistent with the information on the website.
二、概要设计
三、详细设计(详细描述具体如何实现,附代码及说明)
-
在Eclipse 中安装Selenium:
1)将Selenium的jar包放在项目文件夹下的libs文件夹中;
2)使用菜单进行build; -
在Firefox中安装SeleniumIDE:
1)在百度搜索add-ons进入Firefox附加组件的下载页面;
2)搜索下载SeleniumIDE; -
使用SeleniumIDE进行录制:
1)打开SeleniumIDE,新建一个项目;
2)输入BASE URL: http://www.baidu.com;
3)在百度输入框中搜索天津大学;
4)Verify Title
5)结束录制;
6)查看录制结果。 -
在Eclipse中使用Selenium工具检查记录:
1)定义一个Selenium中的WebDriver;
2)设置driver的属性;
3)使用while循环依次读入并检验excel中的信息;
a. 读入一条excel信息;
b. 使用driver从网站上获取对应信息;
c. 使用Junit的assertEquals函数检验两者是否相符。
四、调试分析(在实验过程中遇到的问题以及如何解决)
- driver获取到WebElement发生错误:
查看Junit的报错信息,并在浏览器查看每个元素的属性之后,发现driver的findElement方法使用错误,应该用name属性去查找元素,修改之后运行良好。
五、 测试结果(描述输入和输出)
- 输入:
软件测试名单.excel - 输出:
所有信息正确。
六、 总结
测试结果: