测试用例类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组织测试用例的更多相关文章

  1. testng.xml 执行多个测试用例

    1.在工程名字上点击右键,点击[New]-->[File] 2.在弹出的[New File]对话框中的[File name]输入[testng.xml],点击[Finish]即创建了一个test ...

  2. testng.xml文件的配置

    ------Web自动化测试之Webdriver+TestNG--从零到熟练(系列) TestNG用来管理测试用例的是testng.xml配置文件,我们可以通过配置这个文件来达到组织测试用例,输出测试 ...

  3. testng教程之testng.xml的配置和使用,以及参数传递

    昨天学习了一下testng基础教程,http://www.cnblogs.com/tobecrazy/p/4579414.html 昨天主要学习的是testng 的annotation基本用法和生命周 ...

  4. IDEA 单元测试testng入门及testng.xml

    直接进入正题: 1.TestNG的运行方式如下: With a testng.xml file 直接run as test suite With ant 使用ant From the command ...

  5. 接口自动化框架(java)--5.通过testng.xml生成extentreport测试报告

    这套框架的报告是自己封装的 由于之前已经通过Extentreport插件实现了Testng的IReport接口,所以在testng.xml中使用listener标签并指向实现IReport接口的那个类 ...

  6. testng.xml 配置大全

    1.TestNG的运行方式如下: 1 With a testng.xml file 直接run as test suite 2 With ant 使用ant 3 From the command li ...

  7. TestNG 入门指导——理解testng.xml执行/不执行某个包,某个类,某个方法

    这一篇我们主要学习如下几个知识点: ⑴关于testng.xml ⑵创建一个测试套件 ⑶执行testng.xml ⑷在测试套件中创建多个测试用例 ⑸在用例中增加class,packages, metho ...

  8. 【TestNG测试】TestNG、Maven、testng.xml构建测试工程

    创建一个maven工程 使用Idea创建maven工程 ​ 建立类似如上的工程结构,src/main/java,src/test/java,pom.xml,testng.xml,这里由于我们使用工程是 ...

  9. TestNG的testng.xml配置概述

    TestNG提供的annotaions用来辅助定义测试类. TestNG的testng.xml配置文件用来辅助定义执行什么样的测试,即testng.xml更像是一个测试规划. testng.xml配置 ...

随机推荐

  1. Idea Find in Path 全局搜索的功能

    当我们想查找哪些文件中含有某个关键词时,就要依靠Find in Path,相当于一个全局搜索的功能.

  2. 【洛谷P4124】[CQOI2016]手机号码

    手机号码 数位DP模板题 记忆化搜索: #include<iostream> #include<cstring> #include<cstdio> using na ...

  3. JS JavaScript中的this

    this是JavaScript语言中的一个关键字 它是函数运行时,在函数体内部自动生成的一个对象,只能在函数体内部使用. function test() { this.x = 1; } 上面代码中,函 ...

  4. idea常用技巧

    1.如何设置,使IntelliJ IDEA智能提示忽略大小写 打开设置(CTRL+ALT+S)搜索editor,找到“Code Completion”->点击Case sensitive com ...

  5. java面向对象编程思想的理解

    1.我们总说java是一门面向对象编程的语言,那什么是面向对象呢? 我是这样理解的,对象是事物存在的实体,如,猪.狗,花早等都是对象,对象由两部分组成.面向对象编程的三大特点:继承,多态,类是封装对象 ...

  6. QString, Std::string, char *相互转换

    Qt 库中对字符串类型进行了封装,QString 类提供了所有字符串操作方法,给开发带来了便利. 由于第三方库的类型基本上都是标准的类型,即使用std::string或char *来表示字符 (串) ...

  7. LVS NAT,DR,TUN三种负载原理

    负载均衡简单介绍 用通俗的话来说负载均衡,就是通过不同的调度机制将用户的请求分派到后端不同的服务器.缓解服务器的请求压力,实现负载均衡的方案有多种,下面简单说说了解的几种方式: DNS 负载:利用DN ...

  8. mongodb的windows系统下安装

    先下载安装包,地址有下面两个,按需选择吧. https://www.mongodb.com/download-center/v2/community https://www.mongodb.org/d ...

  9. scrapy框架爬取笔趣阁完整版

    继续上一篇,这一次的爬取了小说内容 pipelines.py import csv class ScrapytestPipeline(object): # 爬虫文件中提取数据的方法每yield一次it ...

  10. PHP错误:Warning: preg_replace() [function.preg-replace]: Unknown modifier '[' in

    遇到一个PHP错误,错误提示是 Warning: preg_replace() [function.preg-replace]: Unknown modifier '[' in  .... , 当然了 ...