一、服务端部署
1、安装jdk
2、安装Android SDK
3、安装nodejs
4、安装appium
不要使用sudo
npm install appium
5、安装pm2
npm install -g pm2
6、关闭防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
7、启动appium服务
进入目录后执行命令
pm2 start .
二、客户端部署(以Java为例)
maven引入相关jar包
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>5.0.0-BETA9</version>
<scope>test</scope>
</dependency>
示例程序
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.MalformedURLException;
import java.net.URL;
public class CalculatorTest {
public static void main(String[] args) throws MalformedURLException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "cc77e79e");//deviceID
capabilities.setCapability("automationName", "Appium");
capabilities.setCapability("platformName", "Android");//操作系统
capabilities.setCapability("platformVersion", "8.0.0");//系统版本
capabilities.setCapability("appPackage", "cn.pear.browser");//应用包名
capabilities.setCapability("appActivity", "cn.pear.browser.activities.WelcomeActivity");//启动页面
AndroidDriver driver = new AndroidDriver(new URL("http://172.25.40.208:4723/wd/hub"), capabilities);//appium服务端连接
Thread.sleep(200000);
driver.quit();
}
}