【问题标题】:How to start the Appium server from command prompt in MAC machine?如何在 MAC 机器中从命令提示符启动 Appium 服务器?
【发布时间】:2014-10-28 19:56:05
【问题描述】:

我正在使用 自动化 本机移动应用程序。到目前为止,我通过单击 Launch 按钮从 Appium GUI 启动服务器。现在我想从命令提示符启动服务器。

按照以下步骤,我可以在 Windows 机器上做同样的事情:

  1. 启动 Node.js 命令提示符
  2. 导航到 Appium bin 文件夹
  3. 使用命令node appium

我无法在 Mac 上启动 Node.js 命令提示符。能否请您告诉我如何在 Mac 上从命令提示符启动 Appium 服务器。

【问题讨论】:

标签: ios appium ios node.js appium


【解决方案1】:

如果你使用 npm install -g appium 那么你应该可以直接用命令打开一个

appium //plus any server args you want ex: appium -p 4474 

或者你仍然可以导航到你的 node_modules 文件夹并进入 appium 并使用

node . //plus any server args you want

如果您想拥有额外的服务器标志,所有这些标志都可以在他们的网站上找到,并附有文档。

【讨论】:

    【解决方案2】:

    打开终端并输入以下命令

    appium --address 127.0.0.1 --port 4723 
    

    按回车键,它将自己注册到 127.0.0.1 并监听 4723 端口。您可以通过添加应用类型等来扩展此命令。

    希望对你有帮助

    干杯

    【讨论】:

      【解决方案3】:
      /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js --address 127.0.0.1 --chromedriver-port 9516 --bootstrap-port 4725 --no-reset --local-timezone --command-timeout 7200 --session-override --debug-log-spacing --platform-version 9.0 --platform-name iOS --app /Users/chennareddy/u/apps/TestApp/build/release-iphonesimulator/Handstand/Handstand.app --show-ios-log --device-name iPhone-6s --native-instruments-lib --orientation Portrait
      

      【讨论】:

      • 这适用于 1.4.12 并允许传递与上面建议的方法不同的功能
      【解决方案4】:

      要在 MAC 中启动 appium,您只需在终端应用程序中输入 => appium &。为了使上述命令正常工作,您必须在终端模式下安装 appium。但是有两种方法,一种是使用 HomeBrew,另一种是直接使用 Node.js。您可以在线找到安装 HomeBrew 的教程。按照下面的步骤直接用 node.js 安装 -

      1. 转到https://nodejs.org/
      2. 在您的 mac 中下载并安装最新稳定版本的 node.js 包
      3. 现在打开终端应用程序
      4. 运行以下命令 => npm install -g appium
      5. 这应该以全局权限在您的系统中安装 Appium。 appium 安装完成后,可以在同一个终端窗口中运行命令 => appium-doctor 来验证是否一切安装正确。
      6. 如果一切都是绿色勾号,运行 => appium & 启动 appium 服务器

      希望这会有所帮助。

      【讨论】:

        【解决方案5】:

        正如其他答案所指出的,如果您已经通过终端安装了 Appium,那么只需在终端窗口上键入 appium & 即可启动 appium 服务器。这里所有你需要知道的,如何通过终端安装 appium。
        1.安装Homebrew

        ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
        

        2。给以下命令一一安装appium

        brew install node      # get node.js
        npm install -g appium  # get appium
        npm install wd         # get appium client
        appium &               # start appium
        

        您可以在此处找到appium download osx 的分步指南。

        【讨论】:

          【解决方案6】:
          String tellCommand = "tell application \"Terminal\" to do script \"/usr/bin/node_modules/appium/bin/appium.js";
                  String parameters = " -p "+port;
                  parameters += " "+ (fullReset ? "--full-reset" : "--no-reset")+"\"";
                  tellCommand += parameters;
          
                  String[] command = { "osascript", "-e",
                  tellCommand };
          
                  ProcessBuilder pBuilder = new ProcessBuilder(command);
                  pBuilder.start();
          

          【讨论】:

            【解决方案7】:

            尝试以编程方式为 mac os 启动您的 appium 服务器,它包括自动化调试所需的 webkit 调试代理。

                //customize the below in start server method
            //Webkit Proxy command
            
            CommandLine iOSProxyCommand = new CommandLine("ios_webkit_debug_proxy");
            iOSProxyCommand.addArgument("-c");
            iOSProxyCommand.addArgument(udid+":27753");//provide your udid of the device
            iOSProxyCommand.addArgument("-F");//to disable console output in eclipse
            
            DefaultExecuteResultHandler iOSProxyresultHandler = new DefaultExecuteResultHandler();
            DefaultExecutor iOSProxyexecutor = new DefaultExecutor();
            iOSProxyexecutor.setExitValue(1);
            try {
            iOSProxyexecutor.execute(iOSProxyCommand, iOSProxyresultHandler);
            iOSProxyCommand.toString()));
            Thread.sleep(5000);
            System.out.println("iOS Proxy started.");
            } catch (IOException e) {
            e.printStackTrace();
            } catch (InterruptedException e) {
            e.printStackTrace();
            }
            
            CommandLine command = new CommandLine(
            "/Applications/Appium.app/Contents/Resources/node/bin/node");
            command.addArgument( "/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js",
            false);
            command.addArgument("--address", false);
            command.addArgument("127.0.0.1");
            command.addArgument("--port", false);
            command.addArgument("4723");
            command.addArgument("--full-reset", false);
            command.addArgument("--log-level", false);//to disable console output in eclipse
            command.addArgument("error");
            command.addArgument("--log", false);
            Timestamp currentTimestamp = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime());
            command.addArgument("/Users/sethupandi/appium"+currentTimestamp+".log");
            DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
            DefaultExecutor executor = new DefaultExecutor();
            executor.setExitValue(1);
            try {
            executor.execute(command, resultHandler);
            Thread.sleep(5000);
            System.out.println("Appium server started.");
            } catch (IOException e) {
            e.printStackTrace();
            } catch (InterruptedException e) {
            e.printStackTrace();
            }
            }
            
            //customize the below in stop appium server-
            
            //kill appium node after end of your execution
            String[] command = { "/usr/bin/killall", "-9", "node" };
            try {
            Runtime.getRuntime().exec(command);
            System.out.println("Appium server stopped.");
            } catch (IOException e) {
            e.printStackTrace();
            }
            //Kill webkit proxy for iOS
            String[] commandProxy = { "/usr/bin/killall", "-9", "ios_webkit_debug_proxy" };
            try {
            Runtime.getRuntime().exec(commandProxy);
            System.out.println("iOS Webkit proxy stopped");
            } catch (IOException e) {
            e.printStackTrace();
            }
            

            【讨论】:

              【解决方案8】:

              对于阅读本文的任何碰巧使用 npm (node/js/typescript) 的人,我创建了一个名为 appium-controller 的模块,它以编程方式(mac 或 windows)在后台启动和停止 appium。它可以选择通过对方法的节点调用或通过 cli 传入特定端口。

              【讨论】:

                猜你喜欢
                • 2019-06-19
                • 2014-07-07
                • 1970-01-01
                • 2017-10-15
                • 1970-01-01
                • 2011-12-17
                • 2013-05-17
                • 1970-01-01
                相关资源
                最近更新 更多