TestNG 运行Webdriver测试用例
1.单击选中的新建工程的名称,按Ctrl+N组合键,弹出对话框选择"TestNG"下的"TestNG class"选项,点击“next”

2.如下图填写完成后,点击“Finish”

3.eclipse会自动生成如下代码:
package cn.gloryroad; import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod; public class FirstTestNGDemo {
@Test
public void f() {
}
@BeforeMethod
public void beforeMethod() {
} @AfterMethod
public void afterMethod() {
} }
4.补充测试用例后,脚本如下:
package cn.gloryroad; import java.sql.Driver; import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod; public class FirstTestNGDemo { public WebDriver driver;
String baseUrl= "http://baidu.com/";
@Test
public void test() { driver.get(baseUrl+'/');
driver.findElement(By.id("kw")).sendKeys("selenium");
driver.findElement(By.id("su")).click();
}
@BeforeMethod
public void beforeMethod() { System.setProperty("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
driver = new FirefoxDriver();
} @AfterMethod
public void afterMethod() {
driver.quit();
} }
5.运用testNG运行脚本,运行结果如下:

6.testNG也会输出HTML格式的测试报告,访问工程目录下的“test-output”目录下

TestNG 运行Webdriver测试用例的更多相关文章
- 持续集成:TestNG组织如何测试用例
持续集成:TestNG组织如何测试用例 poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣,请大家咨询qq:90 ...
- 持续集成:TestNG组织如何测试用例 1
持续集成:TestNG组织如何测试用例 poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标.如果对课程感兴趣,请大家咨询qq:90 ...
- testng入门教程11 TestNG运行JUnit测试
现在,您已经了解了TestNG和它的各种测试,如果现在担心如何重构现有的JUnit代码,那就没有必要,使用TestNG提供了一种方法,从JUnit和TestNG按照自己的节奏.也可以使用TestNG执 ...
- 使用testng.xml组织测试用例
测试用例类TeseNG.java: import org.openqa.selenium.By;import org.openqa.selenium.WebDriver;import org.open ...
- Testng 运行Cannot find class in classpath
用Testng运行多个class,结果报: org.testng.TestNGException: Cannot find class in classpath: Salesman at or ...
- Python3.x:chrome运行webdriver脚本提示--ignore-certificate-errors
Python3.x:chrome运行webdriver脚本提示--ignore-certificate-errors 1,分析原因: 根本原因是Chromedriver和Chrome的版本不兼容: 网 ...
- TestNG简单的学习-TestNG运行
转载:http://topmanopensource.iteye.com/blog/1983735 TestNG简单的学习-TestNG运行 文档来自官方地址: http://testng.org/d ...
- 记录java+testng运行selenium(四)--- 运行代码
涉及的文件有: .\medical\BusinessFile.java :实例化excel及xml文件操作对象以及将list变成Map .\medical\manual\business\LoginB ...
- testng入门教程1在testng运行一个简单的testcase
在eclips运行java,创建一个Java类文件名TestNGSimpleTest C:\ > TestNG_WORKSPACE import org.testng.annotations. ...
随机推荐
- 可恶的Math.random()
生成随机数1-10 (包含1和10) 结果是这样的:Math.floor(Math.random()*10+1) 那么问题又来了 Math.floor(Math.random()*10)生成的只 ...
- 严重危害警告!Log4j 执行漏洞被公开!
12 月 10 日凌晨,Apache 开源项目 Log4j2 的远程代码执行漏洞细节被公开,漏洞威胁等级为:严重. Log4j2 是一个基于 Java 的日志记录工具.它重写了 Log4j 框架,引入 ...
- pwnable_start & ciscn_2019_es_2 & ez_pz_hackover_2016 & pwn2_sctf_2016
花了两天时间做了这四道题,感觉收获很多.但是这种收获感觉写文章写不出自己的思路,就录制了一个视频. pwnable_start 这道题考察了系统调用,shellcode的编写,和动态调试的知识. ci ...
- oracle同义词创建(synonym)
oracle同义词创建(synonym) 在现在的项目中会有很多接口,数据来源也可能是不同数据库或者是不同的用户下的表,给访问该表带来了一定的麻烦.这个时候就可以使用同义词来简化. 同义词的语法是 ...
- Excel数据导出功能
HTML代码: <a id="aExportData" hidden><span>Export</span></a> <div ...
- java 常用类库:操作系统System类,运行时环境Runtime
System类: System 类代表Java程序的运行平台,程序不能创建System类的对象, System类提供了一些类变量和类方法,允许直接通过 System 类来调用这些类变量和类方法. Sy ...
- C++11 新特性:enable_shared_from_this
enable_shared_from_this是一个模板类,定义于头文件<memory>,其原型为:template< class T > class enable_share ...
- Java高级:条件队列与同步器Synchronizer的原理+AQS的应用
14.构建自定义的同步工具 类库中包含了许多存在状态依赖性的类,例如FutureTask,Semaphore和BlockingQueue等.在这些类中的一些操作中有着基于状态的前提条件,例如,不能从一 ...
- IDEA控制台中文显示乱码处理
加入 -Dfile.encoding=UTF-8 以及
- LocalDateTime与Date相互转换
LocalDateTime 转 Date LocalDateTime localDateTime=LocalDateTime.now() Date date = Date.from(localDate ...