一: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的测试框架运用的更多相关文章

  1. TestNG 搭建测试框架 自动化测试

    框架层级及基本组件:    参考:https://www.cnblogs.com/jier888/p/8998724.html Java作为开发语言 Maven管理项目及Jar包 Testng作为测试 ...

  2. TestNG测试框架在基于Selenium进行的web自动化测试中的应用

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ TestNG+Selenium+Ant TestNG这个测试框架可以很好的和基于Selenium的 ...

  3. java 测试框架 TestNG

    Java中print.printf.println的区别 printf主要是继承了C语言的printf的一些特性,可以进行格式化输出 print就是一般的标准输出,但是不换行 println和prin ...

  4. 用maven搭建 testNG+PowerMock+Mockito测试框架

    单元测试是开发中必不可少的一部分,是产品代码的重要保证. Junit和testNG是当前最流行的测试框架,Junit是使用最广泛的测试框架,有兴趣的话自己baidu一下. testNG基于Junit和 ...

  5. 白盒测试的学习之路----(四)搭建测试框架TestNG测试

    TestNG是一个开源自动化测试框架; TestNG是类似于JUnit,但它不是一个JUnit扩展.它的灵感来源于JUnit.它的目的是优于JUnit的,尤其是当测试集成的类. TestNG消除了大部 ...

  6. Java高级特性 第10节 IDEA和Eclipse整合JUnit测试框架

    一.IDEA整合Junit测试框架 1.安装插件 打开File菜单的下拉菜单settings[设置] : 点击左侧Plugins[插件]菜单 在输入框中输入JUnitGenerator 2.0,点击I ...

  7. JAVA 利用MyEclipse结合TestNG测试框架进行单元测试

    利用MyEclipse结合TestNG测试框架进行单元测试   by:授客 QQ:1033553122 测试环境 jdk1.8.0_121 myeclipse-10.0-offline-install ...

  8. java测试框架详细说明-mvn+testng+allure

    java测试框架 mvn+testng+allure 1.mvn代码目录结构 2.testng框架 2.1 testng.xml配置 2.2 注解 3.allure插件,方便报告阅览 4.配置文件.p ...

  9. TestNG详解(单元测试框架)

    一.TestNG的优点 1.1 漂亮的HTML格式测试报告 1.2 支持并发测试 1.3 参数化测试更简单 1.4 支持输出日志 1.5 支持更多功能的注解 二.编写TestNG测试用例的步骤 2.1 ...

随机推荐

  1. 解决phpstudy mysql 启动不了的问题

    1.端口监测 查看3306 的端口是否被占用,如占用,停止进程 2.服务没有启动.因为学习python 我把phpstudy的mysql升级到了mysql8.0. sc delete mysql  删 ...

  2. CSS - display:inline-block 相邻元素间有4px的空白间距

    取消“display:inline-block 相邻元素间有4px的空白间距” Demo:http://jsfiddle.net/JSDavi/p6gcx6nx/ 例子: <div sytle= ...

  3. Linux学习二:基于CentOS 6.5的网络配置

    查看网卡信息: ifconfig [root@hadoop01 ~]# ifconfig [正常的显示信息] eth0 Link encap:Ethernet HWaddr :0C::::5C ine ...

  4. 《黑白团团队》第八次团队作业:Alpha冲刺 第一天

    项目 内容 作业课程地址 任课教师首页链接 作业要求 团队项目 填写团队名称 黑白团团队 填写具体目标 认真负责,完成项目 团队项目Github仓库地址链接. [Alpha] Scrum meetin ...

  5. 在android平台打印C语言日志

    在android平台打印C语言日志 1.操作平台:AS2.0 2.步骤如下: 在C代码中添加如下代码: #define LOG_TAG "我的C语言日志:" #define LOG ...

  6. spring的几个重要类和接口

    1.datasource接口是javax.sql包下的接口,不是spring,是javax.sql下的 datasource接口有个重要的方法getConnection()方法 Connection ...

  7. etymology-R

    1)vor = to eat devour vt. 狼吞虎咽地吃光: 吞没,毁灭: 目不转睛地看[de-向下+vour-吃] voracity  n.贪食,贪婪.拉丁词根vor-,vorac-表示吞食 ...

  8. poi判断一行是隐藏的getZeroHeight()

    poi判断一行是隐藏的 getZeroHeight() boolean isZeroHeight = row.getZeroHeight(); if(isZeroHeight){ // 如果为隐藏行就 ...

  9. 《生活在Linux中》之:在Bash的Emacs模式中使用Vim

    export EDITOR=vim ctrl-x ctrl-e

  10. android一个弹出菜单的动画(一)

    先上效果图: 先写Layout文件: <?xml version="1.0" encoding="utf-8"? > <RelativeLay ...