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设备驱动程序学习----3.模块的编译和装载

    模块的编译和装载 更多内容请参考Linux设备驱动程序学习----目录 1. 设置测试系统 第1步,要先从kernel.org的镜像网站上获取一个主线内核,并安装到自己的系统中,因为学习驱动程序的编写 ...

  2. Spring框架的重要问题

    这篇文章总结了一些关于Spring框架的重要问题,这些问题都是你在面试或笔试过程中可能会被问到的. 目录 Spring概述 依赖注入 Spring Beans Spring注解 Spring的对象访问 ...

  3. three.js实现球体地球城市模拟迁徙

    概况如下:1.SphereGeometry实现自转的地球:2.THREE.ImageUtils.loadTexture加载地图贴图材质:3.THREE.Math.degToRad,Math.sin,M ...

  4. Linux基础命令和文件权限

    Linux命令与文件权限 Linux基础命令   reboot  重启   cd         切换目录   cd ..     回到上一级目录   cd ~      回到主目录   cd /  ...

  5. javaScript 基础知识汇总(二)

    1.运算符 术语或者叫法:一元运算符.二元运算符.运算元(参数) let x=0; x=5+2; //5和2为运算元,“+” 为二元运算符: x=-x; //"-" 为一元运算符 ...

  6. spring-cloud-kubernetes与SpringCloud Gateway

    本文是<spring-cloud-kubernetes实战系列>的第五篇,主要内容是在kubernetes上部署一个SpringCloud Gateway应用,该应用使用了spring-c ...

  7. win8调出右侧菜单栏

    1.快捷键:win+c 2.鼠标放在右下角1s

  8. net start mysql提示:服务名无效

    1.win+R打开运行窗口,输入services.msc 2.在其中查看mysql的服务名,我的是MySQL55 3.以管理员身份打开cmd,输入net start MySQL55 出现下图,代表my ...

  9. HDU2767Proving Equivalences tarjan缩点,如何求入度和出度最大值

    给定一个有向图,问最少增加多少条边后变成强连通图    tarjan求求强连通分量并缩点,如果强连通分量个数为1,则需要边数为0,  否则为缩点后点入度和出度的最大值,  证明:当入度或者出度不为0时 ...

  10. POJ-1213 How Many Tables( 并查集 )

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1213 Problem Description Today is Ignatius' birthday. ...