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. SpringBoot中关于Shiro权限管理的整合使用

     转载:https://blog.csdn.net/fuweilian1/article/details/80309192 在整合Shiro的时候,我们先要确定一下我们的步骤: 1.加入Shiro的依 ...

  2. VMware Workstation 15 Pro 永久激活密钥

    VMware Workstation 15 Pro 永久激活密钥   一. 激活密钥 YG5H2-ANZ0H-M8ERY-TXZZZ-YKRV8 UG5J2-0ME12-M89WY-NPWXX-WQH ...

  3. 基于模糊聚类和最小割的层次化三维网格分割算法(Hierarchical Mesh Decomposition)

    网格分割算法是三维几何处理算法中的重要算法,具有许多实际应用.[Katz et al. 2003]提出了一种新型的层次化网格分割算法,该算法能够将几何模型沿着凹形区域分割成不同的几何部分,并且可以避免 ...

  4. Comupter Tools 清单------包含但不限于此

  5. linux安装man中文手册并保留英文man手册

    大家都知道学习linux系统,查找man手册帮助是非常重要的,然而默认linux的man手册是英文文档,快速阅读英文man固然重要,不过配置好中文man也可以让自己更快速地学习!当然英文学习大家还是不 ...

  6. unity编辑器扩展_07(创建对话框,检测按钮的点击,点击按钮后提示信息,保存设置的数据,显示点击按钮后的处理的进度条信息)

    代码: using UnityEditor;using UnityEngine; public class ChangeValue : ScriptableWizard {               ...

  7. Leetcode之深度优先搜索(DFS)专题-200. 岛屿数量(Number of Islands)

    Leetcode之深度优先搜索(DFS)专题-200. 岛屿数量(Number of Islands) 深度优先搜索的解题详细介绍,点击 给定一个由 '1'(陆地)和 '0'(水)组成的的二维网格,计 ...

  8. 在IIS下部署PHP

    没有.net ramework 4.0 的要先安装 dotNetFx40_Full_x86_x64.exe PHP压缩包 推荐用5.6.29版 IIS下PHP压缩包下载地址:"http:// ...

  9. hdu 4081 Qin Shi Huang's National Road System(次小生成树prim)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4081 题意:有n个城市,秦始皇要修用n-1条路把它们连起来,要求从任一点出发,都可以到达其它的任意点. ...

  10. 常用分享功能.超级简单,qq 微信 新浪微博分享

    <div id="share"> <a href="javascript:void(0)" share-type="qzone&qu ...