package TestCases;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
import org.w3c.dom.Document;
import org.openqa.selenium.By;
//添加对webdriver的引用
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import static org.junit.Assert.*;
//添加对DataProvider的引用
import CommonFunction.DataProvide;
import CommonFunction.DataReader;
public class HelloWorld extends DataProvide {
public DataReader dr;//定义DataReader
@Test(dataProvider="Test_xml_dataprovider")//添加dataprovider
public void f(Document params) throws Exception{
//System.out.println("Hello World!");
//创建浏览器,并打开百度
WebDriver driver = new FirefoxDriver();
driver.get("http://www.baidu.com");
//查询从HellWorld.xml中读取的数据
Thread.sleep(5000);
WebElement input=driver.findElement(By.id("kw"));
input.click();
input.sendKeys(dr.readnodevalue(params, "hello", "name"));//读取Xml中的数据并输入到搜索框
Thread.sleep(2000);
WebElement submit=driver.findElement(By.id("kw"));
submit.click();
Thread.sleep(5000);
//检测查询结果
WebElement result=driver.findElement(By.xpath("//div[@id='content_left']/div/h3/a"));
String text=result.getText();
System.out.println(text);
assertNotEquals(0,text.indexOf(dr.readnodevalue(params, "hello", "name")));
driver.quit();
}
@BeforeTest
public void beforeTest() throws Exception {
//System.out.println("beforeTest running!");
dr=new DataReader();//实例化DataReader
init("src/TestData/HelloWorld.xml");//设置数据源
}
@AfterTest
public void afterTest() {
System.out.println("afterTest running!");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
万事开头难,其实开过头后也不容易。测试方面的技术好多啊,多的像天上的繁星,一.俩.仨.四个…在有限的时间里,想做最多的了解,只能从最实用的着手,去除教条式的金科玉律。于是,一个切入点蹦了出来,那就是介绍号称下一代Java测试技术的TestNG。其实这个next generation 也只是相对于Junit 3.8这个版本,在这个版本发布5年之后,从TestNG中借鉴了许多概念的Junit 4才发行,所以了解TestNG同样有助于学习Junit及Unit系列的众多分支。 软件开发是一项风险事业。测试则是缓解项目风险最重要的手段之一。一般来说,我们应该让需求可测试,让测试自动化,让自动化测试变的容易。理念一定要先进,工具一定要先进。将这些先进的理念和工具应用于项目中,提高生产效率,这就是创新的意义所在。(声明:本段不是原创!) TestNG是一个测试框架,不仅仅用来做单元测试,还包括集成测试。利用注解(annotation)来标注测试类。 测试方法的名字不必以test开始,命名灵活; 测试方法可以返回值,不必是void的; 测试方法可以传入参数; 测试类不
资源推荐
资源详情
资源评论
收起资源包目录
Test.zip (64个子文件)
Test
lib
selenium-server-standalone-2.42.2.jar 33.21MB
dom4j-1.6.1.jar 307KB
testng.jar 1.31MB
httpcore-4.3.3.jar 276KB
saxon-8.7.jar 3.12MB
httpclient-4.3.6.jar 578KB
selenium-java-2.43.0.jar 3.68MB
.classpath 1KB
.settings
org.eclipse.jdt.core.prefs 598B
src
TestCases
HelloWorld.java 2KB
TestData
HelloWorld.xml 138B
CommonFunction
DataProvide.java 1KB
DataReader.java 733B
test-output
style.css 2KB
junitreports
TEST-TestCases.HelloWorld.xml 371B
Default suite_Default test.html 13KB
Default suite_groups.html 1KB
jquery-1.7.1.min.js 92KB
ZhongChouOnlineSuite_groups.html 1KB
navigation.html 2KB
testng-reports.js 3KB
passed.png 1019B
bullet_point.png 356B
main.js 7KB
skipped.png 967B
testng-results.xsl 57KB
old
Default suite
testng.xml.html 691B
methods-alphabetical.html 1KB
Default test.properties 34B
main.html 119B
reporter-output.html 39B
toc.html 1KB
methods.html 1KB
groups.html 38B
methods-not-run.html 50B
classes.html 512B
index.html 186B
index.html 731B
testng.css 312B
ZhongChouOnlineSuite.html 14KB
collapseall.gif 157B
testng-failed.xml 564B
emailable-report.html 2KB
testng-results.xml 2KB
navigator-bullet.png 352B
Default suite
Default test.xml 352B
testng-failed.xml 564B
Default test.html 2KB
overview-chart.svg 2KB
Default suite.html 13KB
index.html 12KB
reporterOutput.html 1012B
ZhongChouOnlineSuite_smoketest.html 14KB
failed.png 977B
testng-reports.css 5KB
overview.html 3KB
index1.html 831B
bin
TestCases
HelloWorld.class 2KB
TestData
HelloWorld.xml 138B
CommonFunction
DataReader.class 1KB
DataProvide.class 2KB
testng.xml 236B
.project 380B
build.xml 784B
共 64 条
- 1
资源评论
进击的雷神
- 粉丝: 2w+
- 资源: 37
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于matlab开发的全面详解LTE:MATLAB建模、仿真与实现-simulink.rar
- 自动驾驶定位系列教程二:系统架构.pdf
- 整站程序8优技巧网-8ujq.rar
- 世界各个国家或地区国际域名缩写
- 基于matlab开发的根据rvm回归模型自己编的matlab程序.rar
- 基于matlab开发的该程序为国内一所大学编写的LTE链路层仿真程序,根据LTE标准协议编写的,很容易看懂.rar
- 高效C++学生成绩管理系统:教育技术+C++17编程+数据管理+教务自动化
- 搜索链接要广告分类系统 v2.0-yad20.rar
- 基于matlab开发的Tipping的相关向量机RVM的回归MATLAB程序,有英文注释,可以运行.rar
- 一个点击正反转程序实例,可实现案件电机正反转
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功