Adroid APPIUM实例步骤

1、下载eclipse

2、安装java 配置环境变量

3、eclipse 安装adt android development tools

4、android sdk manager 安装tools 和相应api的sdk版本  (安装api19,底部extras 安装了Android Support Library 和Google usb driver)  sdk管理器的下载代理用 mirrors.neusoft.edu.cn 80 这个代理还是比较快

5、创建虚拟机(AVD)

3、安装nodejs 并添加环境变量: 安装文件名node-v4.1.2-x64.msi

C:\Program Files\nodejs\;

4、安装appium 执行  npm install -g appium 安装,但是这种安装非常慢,而且不知道进度在哪里

下载AppiumForWindows-1.4.0.zip 执行appium-installer.exe安装

安装后添加环境变量:

C:\Program Files (x86)\Appium;C:\Program Files (x86)\Appium\node_modules\.bin;

执行appium-doctor 检查环境是否正常:

C:\Users\dingxz>appium-doctor

Running Android Checks

? ANDROID_HOME is set to "D:\software\sdk\android-sdk_r23.0.2-windows\android-sd

k-windows"

? JAVA_HOME is set to "C:\Program Files\Java\jdk1.7.0_71."

? ADB exists at D:\software\sdk\android-sdk_r23.0.2-windows\android-sdk-windows\

platform-tools\adb.exe

? Android exists at D:\software\sdk\android-sdk_r23.0.2-windows\android-sdk-wind

ows\tools\android.bat

? Emulator exists at D:\software\sdk\android-sdk_r23.0.2-windows\android-sdk-win

dows\tools\emulator.exe

? Android Checks were successful.

? All Checks were successful

6、新建一个android application project项目

7、安装maven

8、 AppiumForWindows_1_4_16_1.zip 下载并安装更新   下载java-client-3.3.0.jar 并导入

http://appium.io/downloads.html(安装 AppiumForWindows_1_4_16_1 需要先安装.net)

https://search.maven.org/#artifactdetails|io.appium|java-client|3.3.0|jar 页面 有pom例子:

加maven pom 文件:

<dependency>

<groupId>io.appium</groupId>

<artifactId>java-client</artifactId>

<version>3.3.0</version>

</dependency>

实际加了pom.xml 文件中,eclipse 提示:failed to read artifact descriptor for io.appium:java-client:jar:3.3.0

同页面右边有完整的例子:

roject Object Model (POM)


<?xmlversion="1.0"encoding="UTF-8"?>

<!--

  ~ Licensed under the Apache License, Version 2.0 (the "License");

  ~ you may not use this file except in compliance with the License.

  ~ See the NOTICE file distributed with this work for additional

  ~ information regarding copyright ownership.

  ~ You may obtain a copy of the License at

  ~

  ~     http://www.apache.org/licenses/LICENSE-2.0

  ~

  ~ Unless required by applicable law or agreed to in writing, software

  ~ distributed under the License is distributed on an "AS IS" BASIS,

  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  ~ See the License for the specific language governing permissions and

  ~ limitations under the License.

  -->

<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>io.appium</groupId>

    <artifactId>java-client</artifactId>

    <version>3.3.0</version>

    <dependencies>

        <dependency>

            <groupId>com.google.code.gson</groupId>

            <artifactId>gson</artifactId>

            <version>2.2.4</version>

        </dependency>

        <dependency>

            <groupId>org.seleniumhq.selenium</groupId>

            <artifactId>selenium-java</artifactId>

            <version>2.48.2</version>

        </dependency>

        <dependency>

            <groupId>junit</groupId>

            <artifactId>junit</artifactId>

            <version>4.11</version>

            <scope>test</scope>

        </dependency>

        <dependency>

            <groupId>org.apache.httpcomponents</groupId>

            <artifactId>httpclient</artifactId>

            <version>4.3.3</version>

        </dependency>

        <dependency>

            <groupId>com.google.guava</groupId>

            <artifactId>guava</artifactId>

            <version>17.0</version>

        </dependency>

        <dependency>

            <groupId>cglib</groupId>

            <artifactId>cglib</artifactId>

            <version>3.1</version>

        </dependency>

        <dependency>

            <groupId>commons-validator</groupId>

            <artifactId>commons-validator</artifactId>

            <version>1.4.1</version>

        </dependency>

    </dependencies>

    <packaging>jar</packaging>

    <name>java-client</name>

    <description>Java client for Appium Mobile Webdriver</description>

    <url>http://appium.io</url>

    <licenses>

        <license>

            <name>Apache License, Version 2.0</name>

            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>

            <distribution>repo</distribution>

        </license>

    </licenses>

    <scm>

        <url>https://github.com/appium/java-client</url>

        <connection>scm:git:git://github.com/appium/java-client.git</connection>

        <developerConnection>scm:git:[email protected]:appium/java-client.git</developerConnection>

    </scm>

    <developers>

        <developer>

            <email>[email protected]</email>

            <name>Jonah Stiennon</name>

            <url>https://github.com/jonahss</url>

            <id>jonahss</id>

        </developer>

        <developer>

            <email>[email protected]</email>

            <name>Sergey Tikhomirov</name>

            <url>https://github.com/TikhomirovSergey</url>

            <id>TikhomirovSergey</id>

        </developer>

    </developers>

    <distributionManagement>

        <snapshotRepository>

            <id>ossrh</id>

            <url>https://oss.sonatype.org/content/repositories/snapshots</url>

        </snapshotRepository>

        <repository>

            <id>ossrh</id>

            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>

        </repository>

    </distributionManagement>

    <build>

        <resources>

            <resource>

                <directory>src/main/resources</directory>

            </resource>

        </resources>

        <plugins>

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>

                <artifactId>maven-source-plugin</artifactId>

                <version>2.2.1</version>

                <executions>

                    <execution>

                        <id>attach-sources</id>

                        <goals>

                            <goal>jar-no-fork</goal>

                        </goals>

                    </execution>

                </executions>

            </plugin>

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>

                <artifactId>maven-javadoc-plugin</artifactId>

                <version>2.9.1</version>

                <executions>

                    <execution>

                        <id>attach-javadocs</id>

                        <goals>

                            <goal>jar</goal>

                        </goals>

                    </execution>

                </executions>

            </plugin>

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>

                <artifactId>maven-gpg-plugin</artifactId>

                <version>1.5</version>

                <executions>

                    <execution>

                        <id>sign-artifacts</id>

                        <phase>verify</phase>

                        <goals>

                            <goal>sign</goal>

                        </goals>

                    </execution>

                </executions>

            </plugin>

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>

                <artifactId>maven-compiler-plugin</artifactId>

                <version>3.3</version>

                <configuration>

                    <source>1.7</source>

                    <target>1.7</target>

                    <compilerId>eclipse</compilerId>

                </configuration>

                <dependencies>

                    <dependency>

                        <groupId>org.codehaus.plexus</groupId>

                        <artifactId>plexus-compiler-eclipse</artifactId>

                        <version>2.5</version>

                    </dependency>

                </dependencies>

            </plugin>

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>

                <artifactId>maven-surefire-plugin</artifactId>

                <version>2.18.1</version>

                <dependencies>

                    <dependency>

                        <groupId>org.apache.maven.surefire</groupId>

                        <artifactId>surefire-junit47</artifactId>

                        <version>2.18.1</version>

                    </dependency>

                </dependencies>

                <executions>

                    <execution>

                        <goals>

                            <goal>test</goal>

                        </goals>

                        <phase>integration-test</phase>

                        <configuration>

                            <includes>

                                <include>**/*Test.java</include>

                            </includes>

                        </configuration>

                    </execution>

                </executions>

            </plugin>

        </plugins>

    </build>

</project>

9、启动appium.exe  点击launch the appium node server

10、 http://appium.io/ 官网有个sample 的例子

例子的地址: https://github.com/appium/sample-code/tree/master/sample-code/examples

下载代码的位置:

https://github.com/appium/sample-code/blob/master/sample-code/examples/java/junit/src/test/java/com/saucelabs/appium/AndroidTest.java

package com.saucelabs.appium;

import static org.junit.Assert.assertEquals;

import io.appium.java_client.AppiumDriver;

import io.appium.java_client.android.AndroidDriver;

import java.io.File;

import java.net.URL;

import java.util.List;

import org.junit.After;

import org.junit.Before;

import org.junit.Test;

import org.openqa.selenium.By;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.remote.DesiredCapabilities;

public class AndroidTest {

private AppiumDriver<WebElement> driver;

@Before

public void setUp() throws Exception {

File classpathRoot = new File(System.getProperty("user.dir"));

File appDir = new File(classpathRoot, "../../../apps/ApiDemos/bin");

File app = new File(appDir, "ApiDemos-debug.apk");

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability("deviceName","Android Emulator");

capabilities.setCapability("platformVersion", "4.4");

capabilities.setCapability("app", app.getAbsolutePath());

capabilities.setCapability("appPackage", "io.appium.android.apis");

capabilities.setCapability("appActivity", ".ApiDemos");

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

}

@After

public void tearDown() throws Exception {

driver.quit();

}

@Test

public void apiDemo(){

WebElement el = driver.findElement(By.name("Animation"));

assertEquals("Animation", el.getText());

el = driver.findElementByClassName("android.widget.TextView");

assertEquals("API Demos", el.getText());

el = driver.findElement(By.name("App"));

el.click();

List<WebElement> els = driver.findElementsByClassName("android.widget.TextView");

assertEquals("Activity", els.get(2).getText());

}

}

11、下载哔哩哔哩动画.apk,

12、配置skd 环境变量, cmd adb 就可以使用了,adb install 该apk

13、启动android里面的被测试应用。同时启动 D:\soft\appium\android-sdk_r23.0.2-windows\android-sdk-windows\tools  sdk tools 下面的bat文件 hierarchyviewer.bat。

被启动的应用在hierarchyviewer 里面显示为粗黑体

14、在测试代码下里面新建一个AppiumTest 类 复制上面测试例子代码中的 setup方法到类的main方法中,复制内容如下:

File classpathRoot = new File(System.getProperty("user.dir"));

File appDir = new File(classpathRoot, "../../../apps/ApiDemos/bin");

File app = new File(appDir, "ApiDemos-debug.apk");

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability("deviceName","Android Emulator");

capabilities.setCapability("platformVersion", "4.4");

capabilities.setCapability("app", app.getAbsolutePath());

capabilities.setCapability("appPackage", "io.appium.android.apis");

capabilities.setCapability("appActivity", ".ApiDemos");

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

复制以后测试类如下:

public static void main(String[] args) throws MalformedURLException  {

AppiumDriver driver;

/*        // TODO Auto-generated method stub

AndroidDriver driver;

File classpathRoot = new File(System.getProperty("user.dir"));

File appDir = new File(classpathRoot, "apps");

File app = new File(appDir, "BiliPlayer.apk");

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability("deviceName","Android Emulator");

capabilities.setCapability("platformVersion", "4.4");

capabilities.setCapability("app", app.getAbsolutePath());

capabilities.setCapability("appPackage", "io.appium.android.apis");

capabilities.setCapability("appActivity", ".ApiDemos");

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

System.out.println("launch");

driver.quit();*/

//设置apk的路径

File classpathRoot = new File(System.getProperty("user.dir"));

File appDir = new File(classpathRoot, "apps");

File app = new File(appDir, "BiliPlayer.apk");

//设置自动化相关参数

DesiredCapabilities capabilities = new DesiredCapabilities();

/*        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");

*/

capabilities.setCapability("deviceName", "emulator-5554");

//设置安卓系统版本

capabilities.setCapability("platformVersion", "4.4");

capabilities.setCapability("platformName", "Android");

//设置apk路径

capabilities.setCapability("app", app.getAbsolutePath());

//设置app的主包名和主类名                                                                                    tv.danmaku.bilixl

capabilities.setCapability("appPackage", "tv.danmaku.bilixl");

capabilities.setCapability("appActivity", ".LauncherActivity");

//初始化

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

}

执行后提示:

xception in thread "main" org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Activity used to start app doesn‘t exist or cannot be launched! Make sure it exists and is a launchable activity) (WARNING: The server did not provide any stacktrace information)

Command duration or timeout: 26.97 seconds

Build info: version: ‘2.48.2‘, revision: ‘41bccdd10cf2c0560f637404c2d96164b67d9d67‘, time: ‘2015-10-09 13:08:06‘

System info: host: ‘ding‘, ip: ‘192.168.56.1‘, os.name: ‘Windows 8.1‘, os.arch: ‘amd64‘, os.version: ‘6.3‘, java.version: ‘1.8.0_45‘

Driver info: io.appium.java_client.android.AndroidDriver

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:422)

at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)

at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)

at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)

at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)

at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)

at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)

at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)

at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)

at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:37)

at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:161)

at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:170)

at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:82)

at com.test.appium.appiumtraining.AppiumTest.main(AppiumTest.java:65)

网上查询这个提示是说路径问题,也不知道具体什么路径问题。
同时也查找到有人在adb shell中 执行am start 启动应用,提供的语句为:
/home/chhagan/android/adt/sdk/platform-tools/adb -s emulator-5554 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.google.android.gm/.ConversationListActivityGoogleMail"
但是不明白am start 的语句是什么意思,随查找android am start 命令, 获得如下信息:

http://blog.csdn.net/bruce0532/article/details/8276919

# am start -n {包(package)名}/{包名}.{活动(activity)名称}

如启动计算器: am start -n com.android.calculator2/com.android.calculator2.Calculator

这个命令中,需要提供程序的包名和activity 名称

随执行命令:am start -n tv.danmaku.bilixl/tv.danmaku.bilixltv.danmaku.bili.LauncherActivity(这个命令没有成功启动)

命令中的: tv.danmaku.bilixl 为包名,tv.danmaku.bilixltv.danmaku.bili.LauncherActivity 为activity 名称,名称来着于re-sign 提示

提示为不能启动:

d:\soft> adb.exe -s emulator-5554 shell "am start -n tv.danmaku.bilixl/tv.danmaku.bilixltv.danmaku.bili.LauncherActivity"

Starting: Intent { cmp=tv.danmaku.bilixl/tv.danmaku.bilixltv.danmaku.bili.LauncherActivity }

Error type 3

Error: Activity class {tv.danmaku.bilixl/tv.danmaku.bilixltv.danmaku.bili.LauncherActivity} does not exist.

d:\soft>

使用: adb logcat>D:\log.txt 获取android日志,启动被测试应用,再查看D:\log.txt 中的记录, 获得日志信息:

I/ActivityManager(  367): START u0 {flg=0x10000000 cmp= tv.danmaku.bilixl/.tv.danmaku.bilixlty.danmaku.bili.LauncherActivity} from pid 2174

让后用这个包名来启动,执行命令:

adb.exe -s emulator-5554 shell "am start -n tv.danmaku.bilixl/.tv.danmaku.bilixlty.danmaku.bili.LauncherActivity"

d:\soft>adb.exe -s emulator-5554 shell "am start -n tv.danmaku.bilixl/.tv.danmaku.bilixlty.danmaku.bili.LauncherActivity"

Starting: Intent { cmp=tv.danmaku.bilixl/.tv.danmaku.bilixlty.danmaku.bili.LauncherActivity }

Error type 3

Error: Activity class {tv.danmaku.bilixl/tv.danmaku.bilixl.tv.danmaku.bilixlty.danmaku.bili.LauncherActivity} does not exist.

结果也是启动不成功。

看样子是获取包名的数据有问题,再搜索 android 获取包名 获得在sdk 相应api版本下面的一个命令 aapt

命令格式为: aapt dump badging xxxx.apk

执行命令: aapt dump badging  D:\soft\appium\android-sdk_r23.0.2-windows\android-sdk-windows\build-tools\19.1.0\BiliPlayer.apk

获得正在的包名和activity名,如下红色标记:

D:\soft\appium\android-sdk_r23.0.2-windows\android-sdk-windows\build-tools\19.1.0>aapt dump badging  D:\soft\appium\android-sdk_r23.0.2-windows\android-sdk-windows\build-tools\19.1.0\BiliPlayer.apk

package: name=‘tv.danmaku.bilixl‘ versionCode=‘304000‘ versionName=‘1.0.0‘

sdkVersion:‘9‘

targetSdkVersion:‘21‘

uses-permission:‘tv.danmaku.bili.permission.MIPUSH_RECEIVE‘

uses-permission:‘android.permission.INTERNET‘

uses-permission:‘android.permission.WAKE_LOCK‘

uses-permission:‘android.permission.WRITE_EXTERNAL_STORAGE‘

uses-permission:‘android.permission.WRITE_MEDIA_STORAGE‘

uses-permission:‘android.permission.ACCESS_ALL_EXTERNAL_STORAGE‘

uses-permission:‘android.permission.ACCESS_NETWORK_STATE‘

uses-permission:‘android.permission.ACCESS_WIFI_STATE‘

uses-permission:‘android.permission.READ_PHONE_STATE‘

uses-permission:‘android.permission.CAMERA‘

uses-feature-not-required:‘android.hardware.camera‘

uses-feature-not-required:‘android.hardware.camera.autofocus‘

uses-feature-not-required:‘android.hardware.touchscreen‘

application-label:‘哔哩哔哩白‘

application-label-ja:‘哔哩哔哩白‘

application-label-zh:‘哔哩哔哩白‘

application-label-zh_HK:‘哔哩哔哩白‘

application-label-zh_CN:‘哔哩哔哩白‘

application-label-zh_TW:‘哔哩哔哩白‘

application-icon-120:‘res/drawable/ic_launcher.png‘

application-icon-160:‘res/drawable-mdpi-v4/ic_launcher.png‘

application-icon-213:‘res/drawable-tvdpi-v4/ic_launcher.png‘

application-icon-240:‘res/drawable-hdpi-v4/ic_launcher.png‘

application-icon-320:‘res/drawable-xhdpi-v4/ic_launcher.png‘

application-icon-480:‘res/drawable-xxhdpi-v4/ic_launcher.png‘

application-icon-640:‘res/drawable-xxxhdpi-v4/ic_launcher.png‘

application: label=‘哔哩哔哩白‘ icon=‘res/drawable-mdpi-v4/ic_launcher.png‘

l aunchable-activity: name=‘tv.danmaku.bili.LauncherActivity‘  label=‘哔哩哔哩白‘ icon=‘res/drawable-mdpi-v4/ic_launcher.png‘

uses-permission:‘android.permission.READ_EXTERNAL_STORAGE‘

uses-implied-permission:‘android.permission.READ_EXTERNAL_STORAGE‘,‘requested WRITE_EXTERNAL_STORAGE‘

uses-feature:‘android.hardware.wifi‘

uses-implied-feature:‘android.hardware.wifi‘,‘requested android.permission.ACCESS_WIFI_STATE, android.permission.CHANGE_WIFI_STATE, or android.permission.CHANGE_WIFI_MULTICAST_STATE permission‘

uses-feature:‘android.hardware.screen.portrait‘

uses-implied-feature:‘android.hardware.screen.portrait‘,‘one or more activities have specified a portrait orientation‘

main

other-activities

search

other-services

supports-screens: ‘small‘ ‘normal‘ ‘large‘ ‘xlarge‘

supports-any-density: ‘true‘

locales: ‘--_--‘ ‘ja‘ ‘zh‘ ‘zh_HK‘ ‘zh_CN‘ ‘zh_TW‘

densities: ‘120‘ ‘160‘ ‘213‘ ‘240‘ ‘320‘ ‘480‘ ‘640‘

native-code: ‘armeabi‘ ‘armeabi-v7a‘ ‘mips‘ ‘x86‘

因此,修改am start 命令:

adb.exe -s emulator-5554 shell "am start -n tv.danmaku.bilixl/tv.danmaku.bili.LauncherActivity"

结果如下:

D:\soft\eclipse-mars\workspace\appiumtraining\apps>adb.exe -s emulator-5554 shell "am start -n tv.danmaku.bilixl/tv.danmaku.bili.LauncherActivity"

Starting: Intent { cmp=tv.danmaku.bilixl/tv.danmaku.bili.LauncherActivity }

启动成功!!!

源来java代码:

capabilities.setCapability("appPackage", "tv.danmaku.bilixl");

capabilities.setCapability("appActivity", ".LauncherActivity");

修改为

capabilities.setCapability("appPackage", "tv.danmaku.bilixl");

capabilities.setCapability("appActivity", "tv.danmaku.bili.LauncherActivity");

运行脚本,也可以启动,脚本运行成功

完整启动脚本java 代码:

import java.io.File;

import java.net.MalformedURLException;

import java.net.URL;

import org.openqa.selenium.remote.CapabilityType;

import org.openqa.selenium.remote.DesiredCapabilities;

import io.appium.java_client.AppiumDriver;

import io.appium.java_client.android.AndroidDriver;

public class AppiumTest {

public static void main(String[] args) throws MalformedURLException  {

AppiumDriver driver;

File classpathRoot = new File(System.getProperty("user.dir"));

File appDir = new File(classpathRoot, "apps");

File app = new File(appDir, "BiliPlayer.apk");

//设置自动化相关参数

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability(CapabilityType.BROWSER_NAME, "");

capabilities.setCapability("deviceName", "emulator-5554");

//设置安卓系统版本

capabilities.setCapability("platformVersion", "4.4");

capabilities.setCapability("platformName", "Android");

//设置apk路径   D:\soft\eclipse-mars\workspace\appiumtraining\apps\BiliPlayer.apk

capabilities.setCapability("app", app.getAbsolutePath());

String abc = app.getAbsolutePath();

//设置app的主包名和主类名                                                                                    tv.danmaku.bilixl

capabilities.setCapability("appPackage", "tv.danmaku.bilixl");

capabilities.setCapability("appActivity", "tv.danmaku.bili.LauncherActivity");

//初始化

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

}

}

14、打开ddms

eclipse -> window ->perspective ->open perspective ->other...  选中ddms

ddms 里面可以看到一些android系统的信息

在ddms 页面 点击左侧:dump view hierarchy for UI Automator 工具,能获取到android页面的元素信息

2015-12-26

时间: 03-25

Adroid APPIUM实例步骤的相关文章

开始一个Android的appium实例

1.查看Android的应用包名和activity的方法 (网上有很多种方法,这里应用的是查看日志的方法) CMD中输入>adb logcat -c >adb logcat ActivityManager:i *:s 然后操作模拟器中要测试的应用,查看日志,结果如下,cmp=应用包名/Activity 参考文件:http://blog.csdn.net/jlminghui/article/details/40622103 2.定位元素 Android SDK的一些工具可以帮助定位,在Andro

appium实例编写(1)---以ContactsTest.apk 操作为例

详情参照   http://www.cnblogs.com/puresoul/p/4696825.html#3326873   自己练习一遍 前言: appium环境搭建参照另一篇博客:http://www.cnblogs.com/alwayswyy/p/4976933.html  ,主要是安装node.js,配置 Android  SDK的各种环境,以及安装客户端的appium. 接下来需要真实的构建一个appium项目来实现手机app(现在以安卓手机为例)的自动化!!! 一.在eclipse

安装11gR2 ASM单实例步骤

环境介绍: Platform:VisualBox 4.3.12 OS:Oracle Linux 5.8 Grid Infrastructure:11.2.0.3 Database:11.2.0.3 一.安装操作系统(略) 二.配置软件安装环境 --安装完以后先配置一个本地yum cd /etc/yum.repos.d/ touch yum_oel5.repo vi yum_oel5.repo 添加以下内容: [oel5] name=Oracle Linux 5.8 x86_64 DVD base

第二章 mac上运行第一个appium实例

一.打开appium客户端工具 1      检查环境是否正常运行: 点击左边第三个图标 这是测试你环境是否都配置成功了 2      执行的过程中,遇到Could not detect Mac OS X Version from sw_vers output: '10.12.1', 原因是appium还没兼容10.10以上的系统 修改兼容适配之后,继续创建ios模拟器

Eclipse+Python3.4+Selenium+Appium安装步骤

1.安装python3.4,并设置环境变量 2.替换Lib文件(或切换到C:\Python34\Script目录下执行pip install -U selenium命令) 3.安装JDK,并配置环境变量(参考http://jingyan.baidu.com/article/bea41d435bc695b4c41be648.html) 4.eclipse安装pydev插件(参考http://www.cnblogs.com/linzhenjie/articles/2639113.html) 5.安装

python 创建一个实例:步骤二 添加行为方法,编写方法

添加方法 class Person(): def __init__(self,name,job=None,pay=0): self.name= name self.job = job self.pay = pay##用封装的设计概念,添加方法:方法只是附加给类并在处理那些类的实例的常规函数.实例是方法调用的主体,并且会自动专递给方法的self 参数. def LastName(self): return self.name.split()[-1] def giveRaise(self,perce

robotframework + appium实例

Open Application http://localhost:4723/wd/hub platformName=Android platformVersion=4.4.2 deviceName=192.168.65.101:5555 unicodeKeyboard=True resetKeyboard=True appActivity=com.xxx.xxx.activity.MainActivity appPackage=com.xxx.xxxsleep 2 Click Element

ssm框架结合axis2实例步骤

本文亲测: 1.从官网下载axis2相关api,地址是:http://axis.apache.org/axis2/java/core/download.html,我下载的是axis2-1.7.6-bin; 2.从axis2-1.7.6-bin里面找到webapp,WEB-INF,将conf,modules,service全部复制到项目下,如下图: 复制到WEB-INF下面(axis2-1.7.6-bin里面有): 3.在项目web.xml中加入axis2支持: <!-- 加入Axis2支持 --

Appium 1.6安装步骤

原来用的Appium1.5.3GUI版本,那为什么升级呢? 为了兼容最新版本的iOS10和Android7 Xcode8升级后,将不支持使用UIAutomation,而是改为使用XCUITest了,并且Xcode8支持了iOS 10,所以变化还是很大的.开发代码都必须使用Xcode8才能编译了.Appium1.5.3不支持使用Xcode8,所以升级Appium1.6来配合测试 Appium1.6,使用XCUITest支持iOS9.3和iOS10:使用UI Automator2支持Android.