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 ...
随机推荐
- springboot-注解讲解
@Configuration:声明我们JdbcConfig是一个配置类 @PropertySource:指定属性文件的路径是:classpath:jdbc.properties 通过@Value为属性 ...
- USACO 2008 Mar Silver 3.River Crossing 动态规划水题
Code: #include<cstring> #include<algorithm> #include<cstdio> using namespace std; ...
- 洛谷 P1328 生活大爆炸版石头剪刀布 模拟
很简单 Code: #include<cstdio> #include<queue> using namespace std; queue<int>A; queue ...
- Python——Day1(笔记代码)
#print('Hello World')"""n1=input('请输入用户名:')print(n1)n2=input('请输入密码:')print(n2)" ...
- a标记地址的几种用法
1.<a href="tel://号码"></a> 手机使用能自动拨打电话 //可以省略 2.<a href="mailto://邮箱&qu ...
- 网络教程(10)回顾ARP和ping数据包
Ping 192.168.20.2 ICMP Echo (Internet Control Message Protocol ICMP Echo request ICMP Echo reply 收到I ...
- OPENGL学习【一】VS2008开发OPENGL程序开发环境搭建
1.VS2008工具自行在网上下载安装,现只提供VS2008开发工具中配置OPENGL环境的详细步骤.开发包及编译工具会在下方一并放出链接. 2.打开CMake的工具,主要的配置信息如下,按照数字顺序 ...
- nyoj8-一种排序
一种排序 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 现在有很多长方形,每一个长方形都有一个编号,这个编号可以重复:还知道这个长方形的宽和长,编号.长.宽都是整数:现 ...
- NOIP2016 DAY2 T1 组合数问题
题目描述 组合数表示的是从n个物品中选出m个物品的方案数.举个例子,从(1,2,3) 三个物品中选择两个物品可以有(1,2),(1,3),(2,3)这三种选择方法.根据组合数的定 义,我们可以给出计算 ...
- assound.conf
pcm.!dmix {type dmixipc_key 5678293ipc_key_add_uid yesslave {pcm "hw:0,0"period_time 0peri ...