TestNG执行测试用例的顺序
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(priority = 3)
//预期会第3次执行
public void testNG_1() throws InterruptedException {
WebElement webElement = driver.findElement(By.xpath(".//*[@id='kw']"));
webElement.clear();
webElement.sendKeys("Selenium"); driver.findElement(By.xpath(".//*[@id='su']")).click();
Thread.sleep(3000); Reporter.log("搜索Selenium的测试用例");
Assert.assertEquals(driver.getTitle(), "Selenium_百度搜索");
driver.navigate().refresh();
} @Test(priority = 2)
//预期会第2次执行
public void testNG_2() throws InterruptedException {
WebElement webElement = driver.findElement(By.xpath(".//*[@id='kw']"));
webElement.clear();
webElement.sendKeys("JMeter"); driver.findElement(By.xpath(".//*[@id='su']")).click();
Thread.sleep(3000); Reporter.log("搜索JMeter的测试用例");
Assert.assertEquals(driver.getTitle(), "JMeter_百度搜索");
driver.navigate().refresh();
} @Test(priority = 1)
//预期会第1次执行
public void testNG_3() throws InterruptedException {
WebElement webElement = driver.findElement(By.xpath(".//*[@id='kw']"));
webElement.clear();
webElement.sendKeys("Appium"); driver.findElement(By.xpath(".//*[@id='su']")).click();
Thread.sleep(3000); Reporter.log("搜索Appium的测试用例");
Assert.assertEquals(driver.getTitle(), "Appium_百度搜索");
driver.navigate().refresh();
} @AfterClass
public void afterClass(){
driver.close();
driver.quit();
} }

TestNG执行测试用例的顺序的更多相关文章
- testng入门教程3用TestNG执行case的顺序
本教程介绍了TestNG中执行程序的方法,这意味着该方法被称为第一和一个接着.下面是执行程序的TestNG测试API的方法的例子. 创建一个Java类文件名TestngAnnotation.java在 ...
- Webdriver+Testng实现测试用例失败自动截图功能
testng执行测试用例的时候,如果用例执行失败会自动截图,方便后续排查问题 1.首先定义一个截图类: package com.rrx.utils; import java.io.File;impor ...
- testng入门教程12 TestNG执行多线程测试
testng入门教程 TestNG执行多线程测试 testng入门教程 TestNG执行多线程测试 并行(多线程)技术在软件术语里被定义为软件.操作系统或者程序可以并行地执行另外一段程序中多个部分或者 ...
- testng入门教程4用TestNG执行case
使用TestNG类执行测试用例.这个类的主入口点在TestNG的框架运行测试.用户可以创建自己的TestNG的对象,并调用它以许多不同的方式: 在现有的testng.xml 合成testng.xml, ...
- 导入testng管理测试用例
1.在pom.xml中增加testng的依赖,以导入testNG 2.在src-main-resources目录下新建xml文件,比如untitled.xml. <?xml version=&q ...
- Robot Framework(十) 执行测试用例——测试执行
3.2测试执行 本节描述如何执行从解析的测试数据创建的测试套件结构,如何在失败后继续执行测试用例,以及如何正常停止整个测试执行. 3.2.1执行流程 执行套房和测试 设置和拆卸 执行顺序 3.2.2继 ...
- Robot Framework(九) 执行测试用例——基本用法
3.1基本用法 Robot Framework测试用例从命令行执行,默认情况下,最终结果是XML格式的输出文件和HTML 报告和日志.执行后,可以组合输出文件,然后使用rebot工具进行后处理. 3. ...
- unitest单元测试TestCase 执行测试用例(一)
前言 unittest单元测试框架不仅可以适用于单元测试,还可以适用自动化测试用例的开发与执行,该测试框架可组织执行测试用例,并且提供了丰富的断言方法,判断测试用例是否通过,最终生成测试结果. uni ...
- 『德不孤』Pytest框架 — 6、Mark分组执行测试用例
目录 1.Pytest中的Mark介绍 2.Mark的使用 3.Mark的注册和使用 4.使用Mark完成失败重试 5.扩展 1.Pytest中的Mark介绍 Mark主要用于在测试用例/测试类中给用 ...
随机推荐
- ROS编译工作区缺少cv_bridge的问题解决
cv_bridge是OpenCV与ROS之间的格式转换桥梁,编译工作区时遇到报错(目标不存在),直接将cv_bridge包复制到指定的目录即可. 下载地址:https://github.com/ros ...
- 【luogu P2324 [SCOI2005]骑士精神】 题解
题目链接:https://www.luogu.org/problemnew/show/P2324 不懂怎么剪枝,所以说,,我需要氧气.. 第一道A* // luogu-judger-enable-o2 ...
- 【题解】洛谷P1066 [NOIP2006TG] 2^k进制数(复杂高精+组合推导)
洛谷P1066:https://www.luogu.org/problemnew/show/P1066 思路 挺难的一道题 也很复杂 满足题目要求的种数是两类组合数之和 r的最多位数m为 w/k(当w ...
- Oracle中with关键字的使用
open p_cr1 for with sqla as (select d.*, (select c.STATICMONTH from ly_zg_jzfbtstatic c where c.ID = ...
- SQL里的concat() 以及group_concat() 函数的使用
实例参考:https://blog.csdn.net/mary19920410/article/details/76545053 一 concat()函数 1.功能:将多个字符串连接成一个字符串. 2 ...
- 冒泡排序_C语言_数组
冒泡排序_C语言_数组 #include <stdio.h> //冒泡排序 小->大 void sort(int * pArray, int len); int main(int a ...
- Invalid default value for prop "value": Props with type Object/Array must use a factory function to return the default value.(props default 数组/对象的默认值应当由一个工厂函数返回)
Invalid default value for prop "value": Props with type Object/Array must use a factory fu ...
- noip2018 洛谷 P1969积木大赛
1 //一定不要忘记这句话 “连续区间 ”!! #include<bits/stdc++.h> using namespace std; int main(){ int n, h;//n是 ...
- ABAP术语-Connection Type
Connection Type 原文:http://www.cnblogs.com/qiangsheng/archive/2008/01/17/1042479.html A connection ty ...
- 【Linux】wget: command not found的两种解决方法
1.rpm 安装 下载wget的RPM包: http://mirrors.163.com/centos/6.8/os/x86_64/Packages/wget-1.12-8.el6.x86_64.rp ...