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.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 APPTest2 {

AppiumDriver<WebElement> driver;

@BeforeMethod

public void beforeMethod() throws MalformedURLException{

//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);

}

@Test(dataProvider = "testDatas")

//拿到数据提供者的数据,循环这个二维数组,提取元素(一维数组),会把一维数组中的每个元素依次注入到形式参数里

//可以把数据提供者的数据注入到测试方法的形式参数里

public void TestCase(String nickName,String mobilPhone,String pwd ) throws MalformedURLException, InterruptedException {

//3;找到页面元素

//自动化:程序自动定位到页面元素

Thread.sleep(10000);

WebElement registerBtn = driver.findElement(By.id("d36"));

Thread.sleep(10000);

registerBtn.click();

Thread.sleep(1000);

//4;操作页面元素来模拟用户操作

//测试用例,进入注册页面,如 昵称、手机号、密码都不输入的情况,然后点击注册

List<WebElement> elements = driver.findElements(By.id("ht"));

// 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);//断言判断是否可以点击

driver.quit();

}

@DataProvider

public Object[][] testDatas(){

//int[] array1 = {1,2,3,4};//静态数组

Object[][] datas = {{"","",""},{"shashe","",""},{"shashe","15111917843",""}};

return datas;

}

}

APP自動化測試腳本2的更多相关文章

  1. APP自動化測試腳本3

    package com.lemon.day01; import java.net.MalformedURLException; import java.net.URL; import java.uti ...

  2. APP自動化測試腳本1

    package com.lemon.day01; import java.net.MalformedURLException; import java.net.URL; import java.uti ...

  3. Selenium自動化測試(Python+VS2013)-基礎篇-環境安裝

    Python+VS2013環境安裝 http://www.cnblogs.com/aehyok/p/3986168.html PTVS: http://microsoft.github.io/PTVS ...

  4. PCB電路板為何要有測試點?

    對學電子的人來說,在電路板上設置測試點(test point)是在自然不過的事了,可是對學機械的人來說,測試點是什麼?可能多還有點一頭霧水了.我記得我第一次進電子組裝廠工作當製程工程師的時候,還曾經為 ...

  5. ASP.NET MVC 單元測試系列

    ASP.NET MVC 單元測試系列 (7):Visual Studio Unit Test 透過 Visual Studio 裡的整合開發環境 (IDE) 結合單元測試開發是再便利不過的了,在 Vi ...

  6. Postman - 測試 API 的好工具

    POSTMAN in Google APP Store 因為工作的關係,常常寫一些 API 供 APP 使用.以前傻傻的,每次測試的時候都會自己刻一個 HTML 的表單,一個一個填入 input ,接 ...

  7. 一起來玩鳥 Starling Framework(2)效能測試以及Image與Texture

    上一篇我們放了一個Quad與TextField在舞台上慢慢轉.眼尖的可能會發現轉起來邊緣有點鋸齒,這可以透過設定Starling的反鋸齒來解決,在Main.as裡,新增了_starling之後,可以加 ...

  8. 測試大型資料表的 Horizontal Partitioning 水平切割

    FileGroup 檔案群組 :一個「資料庫(database)」可對應一或多個 FileGroup,一個 FileGroup 可由一或多個 file (.ndf) 構成. FileGroup 可讓 ...

  9. [转] [Visual Studio 2012] 找回 建立單元測試 選單

    原文链接:http://www.dotblogs.com.tw/yc421206/archive/2013/03/08/95920.aspx Step1.建立選單 在VS2012選單,Tools→Cu ...

随机推荐

  1. 良许Linux | Linux学习方法及学习资料汇总

    很多人想学习Linux,却不知道怎么着手,甚至不知道Linux有哪些方向,非常迷茫.基于此,我特地写了篇文章介绍Linux方向性问题,没想到一不小心成了爆款: 到什么程度才叫精通 Linux?​ 看完 ...

  2. ajax后台处理响应(java)

    public static final void sendAsJson(HttpServletResponse response, String str) { response.setContentT ...

  3. VS2019没有.net core3.0模板的解决办法

    今天装好了,net core sdk 3.0之后,打开Visual Studio2019后,新建项目时发现尽然没有.net core3.0的模板. 搜了下其他博主的文章,按照文章里做了如下设置:   ...

  4. Anaconda的详细安装步骤图文并茂

    Anaconda(官方网站)就是可以便捷获取包且对包能够进行管理,同时对环境可以统一管理的发行版本.Anaconda包含了conda.Python在内的超过180个科学包及其依赖项. 事实上Anaco ...

  5. 关于Socket、TCP/IP、HTTP、FTP及网络编程

    来源:陶邦仁 链接:http://blog.jobbole.com/99694/ 既然是网络传输,涉及几个系统之间的交互,那么首先要考虑的是如何准确的定位到网络上的一台或几台主机,再者如何进行可靠高效 ...

  6. FEL,项目实装记录

    FEL,即Fast EL ,版本0.8,具体内容我就不贴了,自行百度 实装遇到的问题: Spring Boot 打包后无法进行表达式编译. 根据百度以及源码,确定这东西是在用JavaCompiler将 ...

  7. HDU - 1392 Surround the Trees (凸包)

    Surround the Trees:http://acm.hdu.edu.cn/showproblem.php?pid=1392 题意: 在给定点中找到凸包,计算这个凸包的周长. 思路: 这道题找出 ...

  8. 2019 Multi-University Training Contest 1

    2019 Multi-University Training Contest 1 A. Blank upsolved by F0_0H 题意 给序列染色,使得 \([l_i,r_i]\) 区间内恰出现 ...

  9. hdu 5974 A Simple Math Problem(数学题)

    Problem Description Given two positive integers a and b,find suitable X and Y to meet the conditions ...

  10. yzoj P1122 阶乘 题解

    T组数据,给出N,求出N!最右边非零的数. 对于30%的数据,N <= 30,T<=10. 对于全部的数据,N <= 10^2009,T<=30. 一道数学题 解析 N!/(1 ...