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.Test;

import io.appium.java_client.AppiumDriver;

import io.appium.java_client.android.AndroidDriver;

public class APPTest {

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

public void TestCase001() 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("");

// WebElement mobilPhoneInput = driver.findElement(By.id("ht"));

// mobilPhoneInput.sendKeys("");

elements.get(1).sendKeys("");

// WebElement pwdInput = driver.findElement(By.id("ht"));

//pwdInput.sendKeys("");

elements.get(2).sendKeys("");

WebElement registerBtnn = driver.findElement(By.id("cw1"));

boolean isEnabled = registerBtnn.isEnabled();//是否被激活

Assert.assertFalse(isEnabled);//断言判断是否可以点击

driver.quit();

}

@Test

public void TestCase002() 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("shashe");

// WebElement mobilPhoneInput = driver.findElement(By.id("ht"));

// mobilPhoneInput.sendKeys("");

elements.get(1).sendKeys("");

// WebElement pwdInput = driver.findElement(By.id("ht"));

//pwdInput.sendKeys("");

elements.get(2).sendKeys("");

WebElement registerBtnn = driver.findElement(By.id("cw1"));

boolean isEnabled = registerBtnn.isEnabled();//是否被激活

Assert.assertFalse(isEnabled);//断言判断是否可以点击

driver.quit();

}

@Test

public void TestCase003() 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("shashe");

// WebElement mobilPhoneInput = driver.findElement(By.id("ht"));

// mobilPhoneInput.sendKeys("");

elements.get(1).sendKeys("15111916767");

// WebElement pwdInput = driver.findElement(By.id("ht"));

//pwdInput.sendKeys("");

elements.get(2).sendKeys("");

WebElement registerBtnn = driver.findElement(By.id("cw1"));

boolean isEnabled = registerBtnn.isEnabled();//是否被激活

Assert.assertFalse(isEnabled);//断言判断是否可以点击

driver.quit();

}

}

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

  1. APP自動化測試腳本3

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

  2. APP自動化測試腳本2

    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. Spring学习之旅(四)--高级装配Bean

    条件化 bean 有时候我们要满足某种情况才将bean 初始化放入容器中. 基于环境初始化不同的 bean 1.申明接口并创建两个实现类 public interface Teacher { void ...

  2. MySQL数据库之单表查询中关键字的执行顺序

    目录 MySQL数据库之单表查询中关键字的执行顺序 1 语法顺序 2 执行顺序 3 关键字使用语法 MySQL数据库之单表查询中关键字的执行顺序 1 语法顺序 select distinct from ...

  3. PHPstorm 运行时出现 Not Fount 解决办法

    PHPstorm 对默认 localhost 有解析问题,需要手动配置 打开菜单栏 Tools->Deployment->configuration,如下图: 我这是配置完的,你的应该什么 ...

  4. Java集合框架之TreeSet浅析

    Java集合框架之TreeSet浅析 一.TreeSet综述: 1.1TreeSet简介: TreeSet是Java集合框架的重要成员,先来看看TreeSet在jdk1.8中的定义吧: public ...

  5. Leetcode之分治法专题-169. 求众数(Majority Element)

    Leetcode之分治法专题-169. 求众数(Majority Element) 给定一个大小为 n 的数组,找到其中的众数.众数是指在数组中出现次数大于 ⌊ n/2 ⌋ 的元素. 你可以假设数组是 ...

  6. Java 安全之:csrf防护实战分析

    上文总结了csrf攻击以及一些常用的防护方式,csrf全称Cross-site request forgery(跨站请求伪造),是一类利用信任用户已经获取的注册凭证,绕过后台用户验证,向被攻击网站发送 ...

  7. Windows Server - SVN 服务器搭建与项目配置、客户端安装与配置

    本教程以Windows Server 2012 R12 为例搭建SVN服务器,安装部署完成后,客户端可通过SVN客户端访问SVN服务器上的项目,也可以访问网上其他SVN服务器上的项目. 一.首先准备三 ...

  8. Eureka(一)术语详解(用具体的事物理解抽象的概念)

    最近工作较闲,所以自己研究了下eureka的原理,实现,和集群搭建等.(注:我没实操过eureka集群项目,都是自己做的demo产生的结论,如果有错误欢迎指出) 首先说一下我对eureka的一些术语的 ...

  9. [python]专用下划线标识符

    1. python用下划线作为变量前缀和后缀,来指定特殊变量. _xxx: 不用'from module import *'导入,一般被看作是私有的,在模块或类外不可用使用. __xxx__: 系统定 ...

  10. BZOJ3170 [Tjoi2013]松鼠聚会 切比雪夫距离 - 曼哈顿距离 - 前缀和

    BZOJ3170 题意: 有N个小松鼠,它们的家用一个点x,y表示,两个点的距离定义为:点(x,y)和它周围的8个点即上下左右四个点和对角的四个点,距离为1.现在N个松鼠要走到一个松鼠家去,求走过的最 ...