APP自動化測試腳本3
package com.lemon.day01;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
public class APPTest3 {
AppiumDriver<WebElement> driver;
@BeforeClass
public void beforeClass() throws MalformedURLException, InterruptedException{
//1;添加配置
//手工:找到设备、APP、APP某个页面
DesiredCapabilities desiredcapabilities = new DesiredCapabilities();
desiredcapabilities.setCapability("deviceName","127.0.0.1:52001");//设备名
desiredcapabilities.setCapability("appPackage","com.tencent.mm");//app包,区别我们每台设备的app
//使用命令:adb shell dumpsys activity | find "mFocusedActivity"
desiredcapabilities.setCapability("appActivity","com.tencent.mm.ui.LauncherUI");//指定页面
//2;创建驱动
//remoteAddress:远程url地址
//desiredCapablites :这个驱动期望得到的能力
URL remoteAddress = new URL("http://127.0.0.1:4723/wd/hub");//固定不变的
driver = new AndroidDriver<WebElement>(remoteAddress,desiredcapabilities);
//3;找到页面元素
//自动化:程序自动定位到页面元素
Thread.sleep(10000);
WebElement registerBtn = driver.findElement(By.id("d36"));
Thread.sleep(10000);
registerBtn.click();
Thread.sleep(1000);
}
@AfterClass
public void fun(){
driver.quit();
}
@Test(dataProvider = "testDatas")
//拿到数据提供者的数据,循环这个二维数组,提取元素(一维数组),会把一维数组中的每个元素依次注入到形式参数里
//可以把数据提供者的数据注入到测试方法的形式参数里
public void TestCase(String nickName,String mobilPhone,String pwd ) throws MalformedURLException, InterruptedException {
//4;操作页面元素来模拟用户操作
//测试用例,进入注册页面,如 昵称、手机号、密码都不输入的情况,然后点击注册
List<WebElement> elements = driver.findElements(By.id("ht"));
//每次清空
elements.get(0).clear();
elements.get(1).clear();
elements.get(2).clear();
// WebElement nickNameInput = driver.findElement(By.id("ht"));
//nickNameInput.sendKeys("");//输入字符串
elements.get(0).sendKeys(nickName);
// WebElement mobilPhoneInput = driver.findElement(By.id("ht"));
// mobilPhoneInput.sendKeys("");
elements.get(1).sendKeys(mobilPhone);
// WebElement pwdInput = driver.findElement(By.id("ht"));
//pwdInput.sendKeys("");
elements.get(2).sendKeys(pwd);
WebElement registerBtnn = driver.findElement(By.id("cw1"));
boolean isEnabled = registerBtnn.isEnabled();//是否被激活
Assert.assertFalse(isEnabled);//断言判断是否可以点击
}
@DataProvider
public Object[][] testDatas(){
//int[] array1 = {1,2,3,4};//静态数组
Object[][] datas = {{"","",""},{"shashe","",""},{"shashe","15111917843",""}};
return datas;
}
}
APP自動化測試腳本3的更多相关文章
- APP自動化測試腳本2
package com.lemon.day01; import java.net.MalformedURLException; import java.net.URL; import java.uti ...
- APP自動化測試腳本1
package com.lemon.day01; import java.net.MalformedURLException; import java.net.URL; import java.uti ...
- Selenium自動化測試(Python+VS2013)-基礎篇-環境安裝
Python+VS2013環境安裝 http://www.cnblogs.com/aehyok/p/3986168.html PTVS: http://microsoft.github.io/PTVS ...
- PCB電路板為何要有測試點?
對學電子的人來說,在電路板上設置測試點(test point)是在自然不過的事了,可是對學機械的人來說,測試點是什麼?可能多還有點一頭霧水了.我記得我第一次進電子組裝廠工作當製程工程師的時候,還曾經為 ...
- ASP.NET MVC 單元測試系列
ASP.NET MVC 單元測試系列 (7):Visual Studio Unit Test 透過 Visual Studio 裡的整合開發環境 (IDE) 結合單元測試開發是再便利不過的了,在 Vi ...
- Postman - 測試 API 的好工具
POSTMAN in Google APP Store 因為工作的關係,常常寫一些 API 供 APP 使用.以前傻傻的,每次測試的時候都會自己刻一個 HTML 的表單,一個一個填入 input ,接 ...
- 一起來玩鳥 Starling Framework(2)效能測試以及Image與Texture
上一篇我們放了一個Quad與TextField在舞台上慢慢轉.眼尖的可能會發現轉起來邊緣有點鋸齒,這可以透過設定Starling的反鋸齒來解決,在Main.as裡,新增了_starling之後,可以加 ...
- 測試大型資料表的 Horizontal Partitioning 水平切割
FileGroup 檔案群組 :一個「資料庫(database)」可對應一或多個 FileGroup,一個 FileGroup 可由一或多個 file (.ndf) 構成. FileGroup 可讓 ...
- [转] [Visual Studio 2012] 找回 建立單元測試 選單
原文链接:http://www.dotblogs.com.tw/yc421206/archive/2013/03/08/95920.aspx Step1.建立選單 在VS2012選單,Tools→Cu ...
随机推荐
- spring全家桶的pom的基本配置
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://mave ...
- 关于Function和Object之间先后问题的相关研究
文章说明,博主是一个前端小白,本片文章是博主在学习的过程中碰到的疑惑,根据查找的资料,之后得出的个人结论,文中如果出现错误,欢迎指正. -------路漫漫其修远兮吾将上下而求索,与诸君共勉----- ...
- Java虚拟机详解(八)------虚拟机监控和分析工具(2)——可视化
上篇博客我们介绍了虚拟机监控和分析命令行工具,由于其不够直观,不是很容易排查问题,那么本篇博客我们就来介绍几个可视化工具. 1.JConsole JConsole(Java Monitoring an ...
- Fiddle用于移动端抓包
一.什么情况下可以用到 1.调查参考其他移动端网站的抓包,他们传输方式.如微信上京东的智能机器人的包.移动端的请求接口格式.如何实现的效果等. 2.调试本地移动端页面的测试页面效果是否有问题.如:页面 ...
- safari打不开该网页,因为网址无效
Safari打开导航时,提示:safari打不开该网页 因为网址无效 解决方法:安装百度地图
- codeforces 808 D. Array Division(二分)
题目链接:http://codeforces.com/contest/808/problem/D 题意:有一串长度为n的数组,要求选择一个数字交换它的位置使得这串数能够分成两串连续的和一样的数组. 这 ...
- CF994B Knights of a Polygonal Table 第一道 贪心 set/multiset的用法
Knights of a Polygonal Table time limit per test 1 second memory limit per test 256 megabytes input ...
- There is No Alternative CSU - 2097 最小生成树
Description ICPC (Isles of Coral Park City) consist of several beautiful islands. The citizens reque ...
- 使用FreePBX和第三方线路对接
首先搭建好相关环境 在FreePBX的web-gui控制界面进行操作. 通信接口连接--->中继 先创建一条中继线路: 创建中继 设置这条线路 优先级为0 中继名: 设置一个名字 Outgoi ...
- CentOS 磁盘扩容
本人对Linux本来就不是很熟,但是由于各种原因开始捣鼓CentOS(大家都说是这个系统比较好学),开始预计20G的磁盘就足够了,没想到装Oracle就直接报磁盘空间不足,更别提在Tomcat下部署近 ...