testng+selnium+eclipse的测试框架运用
一:TestNG在Eclipse中的安装
(1)点击eclipse中的Help->Install New Software
(2)点击【Add】按钮,输入相应的地址
(3)勾选加载出来的TestNG选项,点击【Install】
这样就完成了testng在eclipse的安装
二:TestNG在Eclipse中的配置
(1)新建一个项目,选择项目名称点击右键,选择Build Path->【Add Libraties】,添加TestNG

(2)新建一个TestNg Class,并且配置testng.xml文件

三:添加并运行selenium
(1)添加selenium相应的jar包(前面文章已经介绍)
(2)把selenium运行的代码添加到TestNG Class中
比如:
package Testng_findElement; import java.util.Iterator;
import java.util.List;
import java.util.Set; import javax.swing.text.AbstractDocument.Content; import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import TestHelloWorld.Constant;
import TestHelloWorld.DriverUtils; public class Testng_exp {
WebDriver driver; @BeforeTest
public void pre() {
System.setProperty("webdriver.firefox.bin",
"E:/Program Files/Mozilla Firefox/firefox.exe");
driver = new FirefoxDriver();
} @Test
public void Basic_by() {
driver.get("https://www.jd.com");
driver.manage().window().maximize(); // by classname的用法
WebElement text = driver.findElement(By.className("text"));
text.sendKeys("连衣裙");
Actions builder = new Actions(driver);
builder.sendKeys(Keys.ENTER).perform(); // by id的用法
driver.findElement(By.id("ttbar-myjd")).click();
WebDriver window = DriverUtils.getWantDriver(driver,
Constant.jd_login_title);
// by name的用法
WebElement loginname = window.findElement(By.name("loginname"));
loginname.sendKeys(Constant.name);
WebElement nloginpwd = window.findElement(By.name("nloginpwd"));
nloginpwd.sendKeys(Constant.pwd);
window.findElement(By.id("loginsubmit")).click();
}
@AfterTest
public void later(){
driver.close();
} }
(3)让程序飞起来(运行testng.xml)

testng+selnium+eclipse的测试框架运用的更多相关文章
- TestNG 搭建测试框架 自动化测试
框架层级及基本组件: 参考:https://www.cnblogs.com/jier888/p/8998724.html Java作为开发语言 Maven管理项目及Jar包 Testng作为测试 ...
- TestNG测试框架在基于Selenium进行的web自动化测试中的应用
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ TestNG+Selenium+Ant TestNG这个测试框架可以很好的和基于Selenium的 ...
- java 测试框架 TestNG
Java中print.printf.println的区别 printf主要是继承了C语言的printf的一些特性,可以进行格式化输出 print就是一般的标准输出,但是不换行 println和prin ...
- 用maven搭建 testNG+PowerMock+Mockito测试框架
单元测试是开发中必不可少的一部分,是产品代码的重要保证. Junit和testNG是当前最流行的测试框架,Junit是使用最广泛的测试框架,有兴趣的话自己baidu一下. testNG基于Junit和 ...
- 白盒测试的学习之路----(四)搭建测试框架TestNG测试
TestNG是一个开源自动化测试框架; TestNG是类似于JUnit,但它不是一个JUnit扩展.它的灵感来源于JUnit.它的目的是优于JUnit的,尤其是当测试集成的类. TestNG消除了大部 ...
- Java高级特性 第10节 IDEA和Eclipse整合JUnit测试框架
一.IDEA整合Junit测试框架 1.安装插件 打开File菜单的下拉菜单settings[设置] : 点击左侧Plugins[插件]菜单 在输入框中输入JUnitGenerator 2.0,点击I ...
- JAVA 利用MyEclipse结合TestNG测试框架进行单元测试
利用MyEclipse结合TestNG测试框架进行单元测试 by:授客 QQ:1033553122 测试环境 jdk1.8.0_121 myeclipse-10.0-offline-install ...
- java测试框架详细说明-mvn+testng+allure
java测试框架 mvn+testng+allure 1.mvn代码目录结构 2.testng框架 2.1 testng.xml配置 2.2 注解 3.allure插件,方便报告阅览 4.配置文件.p ...
- TestNG详解(单元测试框架)
一.TestNG的优点 1.1 漂亮的HTML格式测试报告 1.2 支持并发测试 1.3 参数化测试更简单 1.4 支持输出日志 1.5 支持更多功能的注解 二.编写TestNG测试用例的步骤 2.1 ...
随机推荐
- PhotoZoom放大的图片效果怎么样?清不清晰?
PhotoZoom是一款使用了革命性技术.效果最好的图像无损放大工具.它可以对图片进行放大而没有锯齿,不会失真,让您无与伦比完美放大图像质量. PhotoZoom Pro使用了S-Spline Max ...
- JS 20180416考试
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 快速搭建一个本地的FTP服务器 win10及win7
快速搭建一个本地的FTP服务器 如果需要开发FTP文件上传下载功能,那么需要在本机上搭建一个本地FTP服务器,方便调试. (win10) 第一步:配置IIS Web服务器 1.1 控制面板中找到“ ...
- http请求后台报406错误
1.springMVC的项目,通过浏览器访问后台方法遇到了报406的错误,找了很多原因,最终发现是因为缺少spring-mvc的json配置. 2.添加依赖:jackson-databind.jack ...
- USACO 2008 Mar Silver 3.River Crossing 动态规划水题
Code: #include<cstring> #include<algorithm> #include<cstdio> using namespace std; ...
- 微信小程序打开PDF
具体情况是:微信小程序打开springboot返回的pdf文件.微信端先downloadFile,然后openDocument.但是打开文档一直不成功.后来发现官网的例子没有加fileType,我在参 ...
- CSS - 内联元素span 强制换行失败的可能原因
在CSS中,标签span 强制换行失败:(使用display:block) 可能原因:float:left or float:right
- [bzoj 2726] 任务安排 (斜率优化 线性dp)
3月14日第三题!!!(虽然是15号发的qwq) Description 机器上有N个需要处理的任务,它们构成了一个序列.这些任务被标号为1到N,因此序列的排列为1,2,3-N.这N个任务被分成若干批 ...
- 使用shell脚本定时执行备份mysql数据库
使用shell脚本定时执行备份mysql数据库 #!/bin/bash ############### common file ################ #本机备份文件存放目录 MYSQLBA ...
- 小松之LINUX 驱动学习笔记(开篇)
时间对每个人都是公平的,就看你怎么对待他.每天多努力一点,未来就会轻松一点.作为一名北漂,感受着首都的压力,也曾萌生过逃离北上广的想法,但是,最后我最终还是选择留下来,随着年龄的增长,我已经没有那么多 ...