是否可以下载Appium v​​1.7.2命令行工具(CLI)?

时间:2018-04-18 07:36:44

标签: appium appium-ios appium-android

目前我正在使用Appium Desktop v1.7.2并在运行脚本之前手动启动服务器。但是现在我必须通过代码/程序为v1.7.2启动Appium服务器来进行框架设计。我开始知道Appium Desktop版本不能以程序方式启动(如果我没错)。

任何人都可以告诉我,他们的Appium v​​1.7.2 CLI是否可以下载/可用?如果是的话,任何样本脚本都会有很大的帮助。

2 个答案:

答案 0 :(得分:0)

这是我自己的Appium服务器实用程序类:

import java.io.IOException;
import java.net.ServerSocket;

import org.openqa.selenium.remote.DesiredCapabilities;

import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;
import io.appium.java_client.service.local.flags.GeneralServerFlag;

/**
 * This class handles Appium Server
 * 
 * @author Bill Hileman
 */
public class AppiumServer {

    private AppiumDriverLocalService service;
    private AppiumServiceBuilder builder;
    private DesiredCapabilities cap;

    private int port = 4723;

    public void startServer() {
        // Set Capabilities
        cap = new DesiredCapabilities();
        cap.setCapability("noReset", "false");

        // Build the Appium service
        builder = new AppiumServiceBuilder();
        builder.withIPAddress("0.0.0.0");
        builder.usingPort(port);
        builder.withCapabilities(cap);
        builder.withArgument(GeneralServerFlag.SESSION_OVERRIDE);
        builder.withArgument(GeneralServerFlag.LOG_LEVEL, "error");

        // Start the server with the builder
        service = AppiumDriverLocalService.buildService(builder);
        service.start();
    }

    public void stopServer() {
        service.stop();
    }

    public boolean serverIsRunnning() {

        boolean isServerRunning = false;
        ServerSocket serverSocket;
        try {
            serverSocket = new ServerSocket(port);
            serverSocket.close();
        } catch (IOException e) {
            // If control comes here, then it means that the port is in use
            isServerRunning = true;
        } finally {
            serverSocket = null;
        }
        return isServerRunning;
    }

}

答案 1 :(得分:0)

在mac上:
mkdir your_appium_dir
cd your_appium_dir
npm install appium@1.7.2
cd appium
npm install [这是获取依赖项并下载]

手动启动服务器:
node .
以编程方式启动服务器:[Python代码]
p = subprocess.Popen('node .', cwd=your_appium_dir_path,stdout=subprocess.PIPE, stderr=subprocess.PIPE)