码迷,mamicode.com
首页 > 编程语言 > 详细

Java练习-002

时间:2017-11-16 20:52:41      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:java

package com.syswin.first;

/**

* @author YuFeifei

* @version 2017年11月14日 上午9:12:08

* 类说明:第一个启动类

*/

import io.appium.java_client.android.AndroidDriver;   

import java.io.File;  

import java.net.MalformedURLException;  

import java.net.URL;    

import org.openqa.selenium.remote.DesiredCapabilities;   

import org.testng.annotations.AfterSuite;   

import org.testng.annotations.BeforeSuite;  

import org.testng.annotations.Test;


import com.appium.test.TestngListener; 


public class AppiumTestCase {

private AndroidDriver driver;

public AndroidDriver getDriver() {

return driver;

}

public void setDriver(AndroidDriver driver) {

this.driver = driver;

}

@BeforeSuite

public void beforeSuite() throws MalformedURLException{

//set up appium

File classpathRoot = new File(System.getProperty("user.dir"));//获取当前路径

File appDir = new File(classpathRoot,"apk");//获取apk文件夹的路径

File app = new File(appDir,"Toon-beijing-test.apk");//获取要测试的APP

DesiredCapabilities capabilities = new DesiredCapabilities();//创建DesiredCapabilities对象

capabilities.setCapability("platformName", "Android");//手机操作系统

capabilities.setCapability("deviceName", "test");//真机名称,目前Android不起作用

capabilities.setCapability("platformVersion", 4.3);//Android系统版本

//capabilities.setCapability("app", app.getAbsolutePath());//在手机上安装APP

capabilities.setCapability("appPackage", "com.systoon.beijingtoon");//package 

capabilities.setCapability("appActivity", "com.systoon.toon.user.login.view.WelcomeActivity");

capabilities.setCapability("unicodeKeyboard", "Ture");//输入中文

capabilities.setCapability("resetKeyboard", "Ture");

driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);

}

@AfterSuite

public void afterSuite(){

driver.quit();

}

@Test

public void testMoment() throws Exception{

Thread.sleep(6000);

driver.findElementById("com.systoon.beijingtoon:id/main_tab_icon").click();  //消息tab

driver.findElementById("com.systoon.beijingtoon:id/main_tab_icon").click() ; //消息tab

        driver.findElementById("com.systoon.beijingtoon:id/tv_change_to_trend").click(); //动态

        Thread.sleep(2000);

        driver.findElementById("com.systoon.beijingtoon:id/trends_home_page_float_button").click(); //发布

        driver.findElementById("com.systoon.beijingtoon:id/content_richedit_input").sendKeys("发布的第一个动态");

        Thread.sleep(2000);

        driver.findElementById("com.systoon.beijingtoon:id/content_item_picture_selected").click(); //添加照片

        Thread.sleep(2000);

        driver.findElementById("com.systoon.beijingtoon:id/trends_view_select_sort_item_btn").click();  //拍摄

        Thread.sleep(2000);

        driver.findElementById("com.systoon.beijingtoon:id/trends_video_rec_in_iv").click();  //拍摄

        Thread.sleep(2000);

        driver.findElementById("com.systoon.beijingtoon:id/trend_video_finish_rl").click(); //选中

 

        driver.findElementById("com.systoon.beijingtoon:id/rich_normal_location_layout").click();  //所在位置

        Thread.sleep(2000);

        driver.findElementById("com.systoon.beijingtoon:id/tv_item_plugin_map_listview_addr").click(); //海南地产

        Thread.sleep(2000);

        driver.findElementById("com.systoon.beijingtoon:id/title_right_bt_id").click();  //确定

     

        driver.findElementById("com.systoon.beijingtoon:id/title_right_bt_id").click();  //发送

        

        

}


}


Java练习-002

标签:java

原文地址:http://11424700.blog.51cto.com/11414700/1982533

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!