当前位置:网站首页>【selenium自动化】第四篇,结合testNg
【selenium自动化】第四篇,结合testNg
2022-08-04 06:04:00 【linrui7】
一、添加testNg pom依赖
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
</dependency>
二、使用 入参形式
@BeforeTest
public static void init() {
System.out.println("-----初始化webdriver.chrome.driver-----");
System.setProperty("webdriver.chrome.driver", "chromedriver");
}
@Test(description = "",dataProvider = "uid")
public static void test06(int id,int vlue) throws InterruptedException {
WebDriver webDriver = new ChromeDriver();
webDriver.get("https://mail.qq.com/");
webDriver.switchTo().frame("login_frame");
webDriver.findElement(By.id("u")).sendKeys(vlue + "");
webDriver.switchTo().defaultContent();
webDriver.findElement(By.linkText("基本版")).click();
Thread.sleep(5000);
webDriver.quit();
}
@DataProvider
public Object[][] uid(){
Object[][] objects=new Object[][]{
{
1,88888},
{
2,99999},
{
3,12345}
};
return objects;
}
三、使用群组,只执行部分
<suite name="suite" verbose="1" >
<test name = "test" >
<groups>
<run>
<include name = "group1" />
</run>
</groups>
<packages>
<package name = "com.linrui.Day03" />
</packages>
<classes>
<class name="com.linrui.Day03" />
</classes>
</test>
</suite>
@Test(description = "",dataProvider = "uid",groups = "group1")
public static void test07(int id,int vlue) throws InterruptedException {
WebDriver webDriver = new ChromeDriver();
webDriver.get("https://mail.qq.com/");
webDriver.switchTo().frame("login_frame");
webDriver.findElement(By.id("u")).sendKeys(vlue + "");
webDriver.switchTo().defaultContent();
webDriver.findElement(By.linkText("基本版")).click();
Thread.sleep(5000);
webDriver.quit();
}
四、多窗口切换
@Test(description = "")
public static void test08() throws InterruptedException {
WebDriver webDriver = new ChromeDriver();
webDriver.get("https://baidu.com/");
String windowHandle1 = webDriver.getWindowHandle();
webDriver.findElement(By.xpath("//*[@id=\"s-hotsearch-wrapper\"]/div/a[1]/div")).click();
webDriver.getWindowHandles().forEach(value -> {
System.out.println(windowHandle1 + "\r\n" + value);
webDriver.switchTo().window(value);
if (!value.equals(windowHandle1)) {
System.out.println("URL:" + webDriver.getCurrentUrl());
}
});
Thread.sleep(5000);
webDriver.quit();
}
边栏推荐
- fanuc机器人IO分配报警信号分配无效
- mysql:列类型之float、double
- 拒绝碰运气,导师人品这样了解!
- Network skills: teach you to install batteries on the router, you can still surf the Internet when the power is cut off!
- Triton部署mmdeploy导出的TensorRT模型失败篇
- Praat:语音标注工具【保存为TextGrid文件】
- 对产品设计,架构设计的一点思考
- Based on the EEMD + + MLR GRU helped time series prediction
- 核心价值观编码器【matlab版】
- Error occurred while trying to proxy request项目突然起不来了
猜你喜欢

Error occurred while trying to proxy request项目突然起不来了

matlab封闭曲线拟合 (针对一些列离散点)

MySQL外键(详解)

Computer software: recommend a disk space analysis tool - WizTree

Based on the EEMD + + MLR GRU helped time series prediction

ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)解决办法

MySQL大总结

如何画好业务架构图。
![(19)[系统调用]SSTD hook 阻止关闭](/img/73/e9d591af366db17965d0bf1cf192b7.png)
(19)[系统调用]SSTD hook 阻止关闭

2DCNN, 1DCNN, BP, SVM fault diagnosis and result visualization of matlab
随机推荐
手把手教你Charles抓包工具使用
缓动动画,有关窗口的一些常见操作,BOM操作
fanuc机器人IO分配报警信号分配无效
用matlab打造的摩斯电码加解码器音频版,支持包括中文在内的任意字符
C语言实现-华为太空人手表
什么是多态。
[漏洞问题] log4j漏洞 关于2.17.0升级到2.18.0 方案
CAN协议详解-01
在线问题反馈模块实战(十八):实现excel台账文件记录批量导入功能
LeetCode(剑指 Offer)- 18. 删除链表的节点
Nacos 原理
IDEA 控制台 中文乱码问题(如果网上教程都无法解决你的问题的话)
Hardware Knowledge: Introduction to RTMP and RTSP Traditional Streaming Protocols
HbuilderX 启动微信小程序 无法打开项目
mysql月份比較是否相等
ES6新语法:symbol,map容器
IoU, GIoU, DIoU and CIoU in target detection
专题讲座7 计算几何 学习心得
mysql:列类型之float、double
MySQL错误-this is incompatible with sql_mode=only_full_group_by完美解决方案