Selenium+TestNG+ReportNG Demo
来源:互联网 发布:西安天互数据业绩 编辑:程序博客网 时间:2024/04/29 02:00
1.安装 TestNG 的eclipse插件
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. 所有的测试用例执行完后会生成更加直观的报告
0 0
- Selenium+TestNG+ReportNG Demo
- IDEA+selenium+testng&reportng 环境搭建
- testng+reportng,运行xml
- Testng监听器listener-ReportNg
- 我的自动化测试历程(Selenium+TestNG+Java+ReportNG+Jenkins)
- 我的自动化测试历程(Selenium+TestNG+Java+ReportNG+Jenkins)
- Java+maven+selenium+testng+reportNG+jenkins自动化环境搭建【全网最详细的搭建过程指导】
- idea+maven+testNG,设置reportNG
- Selenium TestNG
- selenium TestNG
- 使用ReportNg生成测试报告(Maven+Appium+TestNg+ReportNg)
- WebDriver+testng+reportng+ant测试框架整合
- Mac Eclipse+Maven+TestNg+ReportNg 生成测试报告
- APP专项性能测试 TestNG ReportNG
- testng + reportng 测试结果邮件发送
- TestNG-Excute selenium with TestNG.
- 当Selenium遇到TestNG
- selenium+testng+junit+eclipse
- 从头认识java-11.3 格式化输出(2)
- MySQL性能优化
- Cmake+vs2013 配置生成source文件——superviseddescend method(SDM)
- D3.js学习笔记七:多系列折线图与图例
- 创建自己的 Core Data Stack
- Selenium+TestNG+ReportNG Demo
- eclipse localhost-config The configuration may be corrupt or incomplete
- 10 条提升 Android 性能的建议
- select按钮的反馈和改变字体的颜色
- 结婚吉日怎么算 按照老规矩选结婚吉日
- android 动态设置textview 中划线 下划线
- Leetcode 第190题 Reverse Bits
- C-018.二进制中的原码、反码和补码以及负数如何转二进制?
- Silverlight操作客户端注册表(优化)(OOB模式)