Selenium+TestNG+ReportNG Demo
2015-12-01 16:30
441 查看
1.安装 TestNG 的eclipse插件
eclispe-->Help-->Install new software, 输入http://beust.com/eclipse
选中TestNG并且进行安装
2.新建一个Java工程,导入Selenium的jar包和TestNG的library
3.新建TestCase(注解是关键)
4.配置要跑的测试用例
5.testng.xml,右键-->Run as TestNG Suite
6.运行结束后,刷新工程,会生成test-ouput文件夹,打开index.html就能看日志
ReportNG部分(Optional):
RepotNG部分(Optional,只为了能生成更加直观好看的报告):
1. 下载ReportNG相关包,并且加到build path
2. 配置Window--> Preferences-->TestNG
3. 所有的测试用例执行完后会生成更加直观的报告
eclispe-->Help-->Install new software, 输入http://beust.com/eclipse
选中TestNG并且进行安装
2.新建一个Java工程,导入Selenium的jar包和TestNG的library
3.新建TestCase(注解是关键)
private WebDriver driver; private String baseUrl; @BeforeTest public void setUp() throws Exception { System.setProperty("webdriver.chrome.driver", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe"); driver = new ChromeDriver(); baseUrl = "http://172.18.1.210"; } @Test public void testSeleniumIDE() throws Exception { driver.get(baseUrl ); driver.findElement(By.id("logName")).clear(); driver.findElement(By.id("logName")).sendKeys("testtest"); driver.findElement(By.id("logPwd")).clear(); driver.findElement(By.id("logPwd")).sendKeys("1111111"); driver.findElement(By.id("loginBtn")).click(); driver.findElement(By.id("logPwd")).click(); driver.findElement(By.id("logPwd")).clear(); driver.findElement(By.id("logPwd")).sendKeys("111111"); driver.findElement(By.id("loginBtn")).click(); } @AfterTest public void tearDown() throws Exception { driver.quit(); }
4.配置要跑的测试用例
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name="com.cpms.testcase.Driver"> <test name="test12"> <classes> <class name="com.cpms.testcase.CPMS001.Login" /> </classes> </test> </suite>
5.testng.xml,右键-->Run as TestNG Suite
6.运行结束后,刷新工程,会生成test-ouput文件夹,打开index.html就能看日志
ReportNG部分(Optional):
RepotNG部分(Optional,只为了能生成更加直观好看的报告):
1. 下载ReportNG相关包,并且加到build path
2. 配置Window--> Preferences-->TestNG
3. 所有的测试用例执行完后会生成更加直观的报告
相关文章推荐
- 针对Ruby的Selenium WebDriver安装指南
- Python中使用 Selenium 实现网页截图实例
- UI自动化测试框架之Selenium关键字驱动
- 使用 Spring 进行单元测试
- 利用 Selenium 自动化 web 测试
- Xampp安装PHPUnit
- selenium学习3 selenium for IE8+WIN7
- TestNG基本概念和注解
- 用C#.NET 与Webdriver写的抓取网页信息的小工具
- TestNG
- [selenium + eclipse + testng]Build environment
- selenium学习笔记(1)--webdriver中时间控件的使用
- 用Selenium RC插件测试远程应用
- ant testng 问题
- ant testng eclipse 环境调试
- [转]TestNG结合Selenium Grid
- 【转】Selenium Grid 个人理解
- webdriver selenium xpath
- 关于selenium webdriver chromedriver下载的问题