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;

}

}

最新文章

  1. node.js下使用RSA加密事例(windows)
  2. wordpress 获取特色图片url方法
  3. Java for LeetCode 226 Invert Binary Tree
  4. node版本管理器nvm(服务器项目相关)
  5. js如何往数组Array中添加元素
  6. CentOS安装nvidia显卡驱动
  7. DBA
  8. 14.6.3.5 Configuring InnoDB Buffer Pool Flushing
  9. Android UI高级交互设计Demo
  10. BZOJ 1797: [Ahoi2009]Mincut 最小割( 网络流 )
  11. Android 开发环境搭建之——ADT-Bundle for Windows
  12. 判定程序员等级,HashMap就够了
  13. vuex 状态管理 通俗理解
  14. [LeetCode] Shortest Distance to a Character 到字符的最短距离
  15. bbs论坛流程
  16. echarts之简单的入门——【二】再增加一个柱状图和图例组件
  17. topcoder srm 450 div1
  18. mysql中between...and..的使用,及时间范围的查询
  19. 一篇文章理清WebGL绘制流程
  20. easyui的日期控件

热门文章

  1. MySQL多表关联数据同时删除
  2. ASP.NET Core Basic 1-1 WebHost与项目配置
  3. unity编辑器扩展_03(在组件中右击创建一个选项,并通过该选项修改该组件下面的字段的值)
  4. Codeforces 1006E
  5. Leetcode之二分法专题-162. 寻找峰值(Find Peak Element)
  6. Python 基础(四)
  7. Codeforces Round #506 (Div. 3) 1029 F. Multicolored Markers
  8. Codeforces 734D. Anton and Chess(模拟)
  9. codeforces 747D. Winter Is Coming(贪心)
  10. SQL数据同步到ELK(二)- Elastic Search 安装