高手的存在,就是让服务10亿人的时候,你感觉只是为你一个人服务......

Appium Desktop

目录
  1. 1.
  2. 2. Appium Desktop安装
  3. 3. Start Inspector Session
    1. 3.1. Appium Desired Capabilities
    2. 3.2. The Inspector
      1. 3.2.1. Recoding

Alt text

Appium Desktop is an open source app for Mac, Windows, and Linux which gives you the power of the Appium automation server in a beautiful and flexible UI.

by https://github.com/appium/appium-desktop


Appium Server在15年就停更了,可以把Appium Desktop看做是Appium Server的升级版,用Appium Desktop替代Appium Server。但其实他们是两个不同的产品。

Appium Desktop特点:

优秀的图形界面。高端大气!
可以进行元素定位,同时支持android和ios。实在是方便,可以把uiautomatorviewer扔了!
支持多语言脚本录制。very good,人性化十足!

如果已经安装了Appium Server的,可以直接卸载了。


Appium Desktop安装

下载地址:https://github.com/appium/appium-desktop/releases/tag/v1.2.7

下载安装即可。

Alt text

点击start server v1.7.1按钮,启动服务。
Alt text


Start Inspector Session

Alt text

可以理解为启动 appium client的UI端。

Appium Desired Capabilities

java appium-client中设置DesiredCapabilities 通过以下方式:

1
2
3
4
5
6
7
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Android Emulator");
capabilities.setCapability("automationName", "Appium");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "6.0");
capabilities.setCapability("appPackage", "com.android.calculator2");
capabilities.setCapability("appActivity", ".Calculator");

而appium desktop提供了UI的方式填写 Appium Desired Capabilities,
Alt text

Desired Capabilities说明文档:

https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/caps.md

点击右下角的Start Session 启动Inspector(时间比较长)。


The Inspector

Inspector 对App进行可视化,方便进行元素定位、脚本录制、调试等,非常人性化。

Alt text

Recoding

对于初学者来说,这里提供了录制功能,方便进行脚本编写。

点击Start Recoding
Alt text

简单录制 1+1=2

Alt text

同时可以选择多种语言。点击生成的java脚本如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;

public class SampleTest {

private AndroidDriver driver;

@Before
public void setUp() throws MalformedURLException {
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("deviceName", "Android Emulator");
desiredCapabilities.setCapability("automationName", "Appium");
desiredCapabilities.setCapability("platformName", "Android");
desiredCapabilities.setCapability("platformVersion", "6.0");
desiredCapabilities.setCapability("appPackage", "com.android.calculator2");
desiredCapabilities.setCapability("appActivity", ".Calculator");

URL remoteUrl = new URL("http://localhost:4723/wd/hub");

driver = new AndroidDriver(remoteUrl, desiredCapabilities);
}

@Test
public void sampleTest() {
(new TouchAction(driver)).tap(110, 901).perform();
(new TouchAction(driver)).tap(644, 1079).perform();
(new TouchAction(driver)).tap(108, 906).perform();
(new TouchAction(driver)).tap(464, 1061).perform();
}

@After
public void tearDown() {
driver.quit();
}
}

使用junit4测试运行:

Alt text