使用testng.xml组织测试用例
测试用例类TeseNG.java: import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.Reporter;
import org.testng.annotations.*; public class TestNG {
private WebDriver driver; @BeforeClass
public void beforeClass() throws InterruptedException {
System.setProperty("webdriver.firefox.marionette",
"src/main/resourcec/geckodriver.exe");
String baiduHomePage;
baiduHomePage = "https://www.baidu.com/"; driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get(baiduHomePage);
Thread.sleep(2000);
Assert.assertEquals(driver.getTitle(), "百度一下,你就知道");
} @Test(dataProvider = "word")
public void testNG(String keyword, String case_1, String searchTitle)
throws InterruptedException {
WebElement webElement = driver.findElement(By.xpath(".//*[@id='kw']"));
webElement.clear();
webElement.sendKeys(keyword); driver.findElement(By.xpath(".//*[@id='su']")).click();
Thread.sleep(3000); Reporter.log(case_1);
Assert.assertEquals(driver.getTitle(), searchTitle);
driver.navigate().refresh();
} @AfterClass
public void afterClass(){
driver.close();
driver.quit();
} @DataProvider(name = "word")
public static Object[][] data(){
return new Object[][]{{"Selenium", "搜索Selenium的测试用例", "Selenium_百度搜索"},
{"JMeter", "搜索JMeter的测试用例", "JMeter_百度搜索"},
{"Appium", "搜索Appium的测试用例", "Appium_百度搜索"}
};
}
} testng.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="百度搜索的测试计划" verbose="2" preserve-order="true"> <test name="分别搜索Selenium/JMeter/Appium的测试用例">
<classes>
<class name="TestNG" />
</classes>
</test> <listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter" />
<listener class-name="org.uncommons.reportng.JUnitXMLReporter" />
</listeners>
</suite>

使用testng.xml组织测试用例的更多相关文章
- testng.xml 执行多个测试用例
1.在工程名字上点击右键,点击[New]-->[File] 2.在弹出的[New File]对话框中的[File name]输入[testng.xml],点击[Finish]即创建了一个test ...
- testng.xml文件的配置
------Web自动化测试之Webdriver+TestNG--从零到熟练(系列) TestNG用来管理测试用例的是testng.xml配置文件,我们可以通过配置这个文件来达到组织测试用例,输出测试 ...
- testng教程之testng.xml的配置和使用,以及参数传递
昨天学习了一下testng基础教程,http://www.cnblogs.com/tobecrazy/p/4579414.html 昨天主要学习的是testng 的annotation基本用法和生命周 ...
- IDEA 单元测试testng入门及testng.xml
直接进入正题: 1.TestNG的运行方式如下: With a testng.xml file 直接run as test suite With ant 使用ant From the command ...
- 接口自动化框架(java)--5.通过testng.xml生成extentreport测试报告
这套框架的报告是自己封装的 由于之前已经通过Extentreport插件实现了Testng的IReport接口,所以在testng.xml中使用listener标签并指向实现IReport接口的那个类 ...
- testng.xml 配置大全
1.TestNG的运行方式如下: 1 With a testng.xml file 直接run as test suite 2 With ant 使用ant 3 From the command li ...
- TestNG 入门指导——理解testng.xml执行/不执行某个包,某个类,某个方法
这一篇我们主要学习如下几个知识点: ⑴关于testng.xml ⑵创建一个测试套件 ⑶执行testng.xml ⑷在测试套件中创建多个测试用例 ⑸在用例中增加class,packages, metho ...
- 【TestNG测试】TestNG、Maven、testng.xml构建测试工程
创建一个maven工程 使用Idea创建maven工程 建立类似如上的工程结构,src/main/java,src/test/java,pom.xml,testng.xml,这里由于我们使用工程是 ...
- TestNG的testng.xml配置概述
TestNG提供的annotaions用来辅助定义测试类. TestNG的testng.xml配置文件用来辅助定义执行什么样的测试,即testng.xml更像是一个测试规划. testng.xml配置 ...
随机推荐
- 2018.12.21 如何在现有的Eclipse(4.9.0版本)中安装STS (Spring Tool Suite ) Mac环境下
在Eclipse中安装STS正确步骤实现方式 1.简介说明 spring Tool Suite(sts)就是一个基于Eclipse的开发环境, 用于开发Spring应用程序.它提供了一个现 ...
- public /protected/private的作用域
作用域 当前类 同一package 子孙类 其他package public √ √ √ √ protected √ √ √ × friendly √ √ × × private √ × × ×
- doppia代码支持
stixels_t在stixel.hpp里,存储class stixel的vector
- 【luogu P2023 [AHOI2009]维护序列】 题解
题目链接:https://www.luogu.org/problemnew/show/P2023 把P3373改一改直接粘过来就A #include <iostream> #include ...
- Python—面向对象 封装03
接着上面的一篇继续往下: 如何隐藏 在python中用双下划线开头的方式将属性隐藏起来(设置成私有的) class A: __x = 1 # _A__x = 1 def __init__(self, ...
- sudo cd的错误
问题说明 今天用MySQL建了库,想看看. 当到了这步,心里的第一个感觉就是电脑坏了.后来查了查才知道了原因. 原因 cd不是一个应用程序而是Linux内建的命令,而sudo仅仅只对应用程序起作用. ...
- 《深入理解Spring Cloud与微服务构建》书籍目录
转载请标明出处: https://blog.csdn.net/forezp/article/details/79735542 本文出自方志朋的博客 作者简介 方志朋,毕业于武汉理工大学,CSDN博客专 ...
- 封装一个方法获取url上面的参数
一.取参 ] : ); ]; ; ]., -); ]) === ]; , , b: 'fdfdfd', c: '9999' })); //a=123546&b=fdfdfd&c=9 ...
- c c++面试c工程开发之宏定义和条件编译
多数c语言的初学者对c工程开发过程各个阶段的作用理解不到位,而这方面的的知识又是实际开发过程中经常用到的技能点,所以就成为面试考察中一个重要的考察方面.例如:头文件的作用.头文件的内容:链接的作用和意 ...
- 通过xshell在linux上安装redis3.0.0
通过xshell在linux上安装redis3.0.0 0)首先要安装环境:yum install gcc-c++ 1)通过xftp6将redis安装包上传到linux:解压缩:tar -xvfz r ...