一: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. Xpath--使用Xpath爬取糗事百科成人版图片

    #!usr/bin/env python#-*- coding:utf-8 _*-"""@author:Hurrican@file: 爬取糗事百科.py@time: 20 ...

  2. nginx (待更新)

    install apt install nginx 默认在 /etc/nginx 目录下 一个 master 以及多个 worker 3504 root 20 0 141M 7196 5552 S 0 ...

  3. DedeCMS用channelartlist调用顶级栏目及列表

    这个标签全局都可使用,可以减少多次使用 {dede:arclist typeid=‘栏目ID’titlelen='60' row='10'}.除了宏标记外,{dede:channelartlist}是 ...

  4. HDU 4704 Sum( 费马小定理 + 快速幂 )

    链接:传送门 题意:求 N 的拆分数 思路: 吐嘈:求一个数 N 的拆分方案数,但是这个拆分方案十分 cd ,例如:4 = 4 , 4 = 1 + 3 , 4 = 3 + 1 , 4 = 2 + 2 ...

  5. 51nod-独木舟问题

    n个人,已知每个人体重,独木舟承重固定,每只独木舟最多坐两个人,可以坐一个人或者两个人.显然要求总重量不超过独木舟承重,假设每个人体重也不超过独木舟承重,问最少需要几只独木舟?分析:  一个显然的策略 ...

  6. Tensorflow 之物体检测

    1)安装Protobuf TensorFlow内部使用Protocol Buffers,物体检测需要特别安装一下. # yum info protobuf protobuf-compiler 2.5. ...

  7. Shell编程入门(第二版)(上)

    简单的示例Shell程序 示例1. #!/bin/bash #This is to show what a shell script looks like echo "Our first e ...

  8. [GraphQL] Mutations and Input Types

    Sometimes, you want to resues object type when doing mutation, you can use 'input' type to help: inp ...

  9. hdu 1754 I Hate It 线段树 点改动

    // hdu 1754 I Hate It 线段树 点改动 // // 不多说,裸的点改动 // // 继续练 #include <algorithm> #include <bits ...

  10. 【分享】GEARS of DRAGOON 1+2【日文硬盘版】[带全CG存档&amp;攻略+SSG改动+打开存档补丁]

    冒险者们哟.寻找龙秘玉吧--! ninetail的最新作,是使用丰富多彩的技能·道具探索迷宫的3D迷宫RPG! 存在着骑士和神官的架空世界常见的职业为首的13种职业.超过数百种的道具的登场! 和伙伴一 ...