【问题标题】:Is it possible to download Appium v1.7.2 command line tools (CLI)?是否可以下载 Appium v​​1.7.2 命令行工具(CLI)?
【发布时间】:2018-09-28 08:20:49
【问题描述】:

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

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

【问题讨论】:

    标签: appium appium-ios appium-android


    【解决方案1】:

    这是我自己的 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;
        }
    
    }
    

    【讨论】:

    • 您是否使用 npm install appium@1.7.2 命令安装了 appium CLI?
    • 是的,我就是这个意思
    【解决方案2】:

    在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)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-28
      相关资源
      最近更新 更多