环境准备
- node.js
- Android SDK
1.Appium启动后
(1)打开放大镜进行配置,用来查找页面元素
-
安卓配置 { “platformName”: “Android”, “platformVersion”: “7.1.12”, “deviceName”: “127.0.0.1:62001”, “appPackage”: “com.taobao.taobao”, “appActivity”: “com.taobao.tao.TBMainActivity” } -
苹果配置(未测试)
(2)Eclipse代码
```java
//Appium服务器暴露的接口,后面是固定的
URL remoteAddress = new URL("http://127.0.0.1:4723/wd/hub");
//需要能力
// deviceName 操作哪一台设备(通过命令查看:adb devices)
// appPackage 哪一个app(通过命令:adb shell dumpsys activity | find "mFocusedActivity" 或百度更多方法)
// appActivity 哪个界面
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("deviceName", "127.0.0.1:62001");
desiredCapabilities.setCapability("appPackage", "com.taobao.taobao");
desiredCapabilities.setCapability("appActivity", "com.taobao.tao.TBMainActivity");
AndroidDriver<WebElement> driver = new AndroidDriver<WebElement>(remoteAddress, desiredCapabilities);
WebElement my = driver.findElement(By.xpath("//android.widget.FrameLayout[@content-desc=\"我的淘宝\"]"));
my.click();
|