ios 如何从 MAC 机器的命令提示符启动 Appium 服务器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25659168/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 02:12:08  来源:igfitidea点击:

How to start the Appium server from command prompt in MAC machine?

iosnode.jsappium

提问by Priyanka Agarwal

I am automating iosnative mobile application using appium. Until now I was launching the server from the Appium GUI by clicking on the Launch button. Now I want to start the server from a command prompt.

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

I was able to do the same in Windows machine by following the below steps:

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

  1. Launch Node.js command prompt
  2. Navigate till the Appium bin folder
  3. Use the command node appium
  1. 启动 Node.js 命令提示符
  2. 导航到 Appium bin 文件夹
  3. 使用命令 node appium

I got blocked on how to start the Node.js command prompt on a Mac. Can you pleases tell me how I can start the Appium server from a command prompt on a Mac.

我被阻止了如何在 Mac 上启动 Node.js 命令提示符。你能告诉我如何从 Mac 上的命令提示符启动 Appium 服务器吗?

回答by SthQA

if you used npm install -g appium then you should be able to directly open one with the command

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

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

Or you can still navigate to the folder of your node_modules and into appium and go with

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

node . //plus any server args you want

if you want to have additional server flags, all are available at their site with documentations.

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

回答by rajan

Open the terminal and type in the following command

打开终端并输入以下命令

appium --address 127.0.0.1 --port 4723 

Press enter then it will register itself to 127.0.0.1 and will listen 4723 port. You can extend this command by adding app type etc.

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

Hope this will help you

希望能帮到你

cheers

干杯

回答by channareddy biradar

/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

回答by Girish Sortur

To start appium in MAC, all you need to do is to type => appium &in the terminal application. In order for the above command to work, you have to install appium in terminal mode. However there are 2 ways of doing it, one is with HomeBrew and the other directly with Node.js . You can find the tutorial of installing HomeBrew online. Follow the steps below to install it directly with node.js -

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

  1. Go to https://nodejs.org/
  2. Download and install the latest stable version of node.js package in your mac
  3. Now open the terminal application
  4. Run the following command => npm install -g appium
  5. This should install Appium in your system with global privileges. After installation of appium, you can run the command => appium-doctorin the same terminal window to verify if everything is installed properly.
  6. If everything is in green ticks, run => appium &to start the appium server
  1. 转到https://nodejs.org/
  2. 在您的 Mac 中下载并安装最新稳定版本的 node.js 包
  3. 现在打开终端应用程序
  4. 运行以下命令 => npm install -g appium
  5. 这应该以全局权限在您的系统中安装 Appium。安装 appium 后,您可以在同一个终端窗口中运行命令 => appium-doctor以验证是否一切安装正确。
  6. 如果一切都是绿色的,运行 => appium &来启动 appium 服务器

Hope this helped.

希望这有帮助。

回答by abhijeet kanade

As other answers points out, if you have installed Appium thru terminal then simply type appium &on a terminal window to start appium server. Here all you need to know, how to install appium thru terminal.
1. Install Homebrew.

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

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

2. Give Following commands one by one to install appium

2. 一一给出以下命令安装appium

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

You can find refer to step by guide for appium download osxhere.

您可以在此处找到有关appium 下载 osx 的分步指南。

回答by Sethu_P

Try this to launch your appium server programmatically for mac os, it includes automating the webkit debug proxy as well which is needed for debugging.

试试这个以编程方式为 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();
}

回答by aaronbriel

For anybody reading this who happens to be using npm (node/js/typescript), I've created a module called appium-controllerthat starts and stops appium in the background programmatically (mac or windows). It has an option to pass in a specific port either through a node call to the method or through cli.

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

回答by Changdeo Jadhav

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();

回答by Kiran Sk

  • Install latest Android studio
  • Install Java SDK from : http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
  • Install Homebrew using
  • Install ruby: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • download installer: https://nodejs.org/en/download/andrun
  • in terminal:
    • brew update
    • brew install node (if permission denied in post install then run "sudo chown -R $(whoami):admin /usr/local/lib/node_modules/“)
    • npm install -g npm
  • Update system preference:?open bash_profile in terminal:
  • nano ~/.bash_profile?
    • paste following:
  • export ANDROID_HOME=/Users/jenkinss/Library/Android/sdk?export PATH=$ANDROID_HOME/platform-tools:$PATH?export PATH=$ANDROID_HOME/tools:$PATH?export JAVA_HOME=$(/usr/libexec/java_home)?
    • save and exit
  • install Appium UI tool form here: https://bitbucket.org/appium/appium.app/downloads/appium-1.5.3.dmg
  • in Terminal install Appium command line:
  • npm install -g [email protected]?npm install wd??
  • now fix Appium beta with:
  • cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
  • brew install carthage?
  • npm i -g webpack?
  • ./Scripts/bootstrap.sh -d??
  • npm install appium-doctor -g
  • run 'appium-doctor —android' and fix the JAVA_PATH and ANDROID_PATH issues
  • run 'appium-doctor —ios'
  • install xcode command line tools if not installed : xcode-select —install
  • brew install libimobiledevice —HEAD
  • npm install -g ios-deploy
  • install appium-xcuitest driver : npm i appium-xcuitest-driver
  • Open WebDriverAgent.xcodeproj from /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent and sign the Lib and runner files
  • brew install ios-webkit-debug-proxy
  • got to : /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/node_modules/appium-xcode/
  • git clone https://github.com/facebook/WebDriverAgent
  • cd WebDriverAgent/
  • ./Scripts/bootstrap.sh
  • open WebDriverAgent.xcodeproj and sign lib and runner
  • git clone https://github.com/google/ios-webkit-debug-proxy.git
  • cd ios-webkit-debug-proxy
  • ./autogen.sh
  • make
  • sudo make install (installed in /usr/local/bin/ios_webkit_debug_proxy)
  • 安装最新的 Android Studio
  • 从以下位置安装 Java SDK:http: //www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
  • 安装 Homebrew 使用
  • 安装 ruby​​: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • 下载安装程序:https: //nodejs.org/en/download/并运行
  • 在终端:
    • 酿造更新
    • brew 安装节点(如果在安装后权限被拒绝,则运行“sudo chown -R $(whoami):admin /usr/local/lib/node_modules/”)
    • npm install -g npm
  • 更新系统首选项:?在终端中打开 bash_profile:
  • nano ~/.bash_profile?
    • 粘贴以下内容:
  • export ANDROID_HOME=/Users/jenkinss/Library/Android/sdk?export PATH=$ANDROID_HOME/platform-tools:$PATH?export PATH=$ANDROID_HOME/tools:$PATH?export JAVA_HOME=$(/usr/libexec/java_home) ?
    • 保存并退出
  • 在此处安装 Appium UI 工具表单:https://bitbucket.org/appium/appium.app/downloads/appium-1.5.3.dmg
  • 在终端安装 Appium 命令行:
  • npm install -g [email protected]?npm install wd??
  • 现在修复 Appium 测试版:
  • cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
  • 酿造安装迦太基?
  • npm i -g webpack?
  • ./Scripts/bootstrap.sh -d??
  • npm install appium-doctor -g
  • 运行“appium-doctor —android”并修复 JAVA_PATH 和 ANDROID_PATH 问题
  • 运行'appium-doctor —ios'
  • 如果未安装,请安装 xcode 命令行工具:xcode-select —install
  • brew install libimobiledevice —HEAD
  • npm install -g ios-deploy
  • 安装 appium-xcuitest 驱动程序: npm i appium-xcuitest-driver
  • 从 /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent 打开 WebDriverAgent.xcodeproj 并对 Lib 和 runner 文件进行签名
  • brew install ios-webkit-debug-proxy
  • 到:/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/node_modules/appium-xcode/
  • git 克隆https://github.com/facebook/WebDriverAgent
  • cd WebDriverAgent/
  • ./Scripts/bootstrap.sh
  • 打开 WebDriverAgent.xcodeproj 并签署 lib 和 runner
  • git 克隆https://github.com/google/ios-webkit-debug-proxy.git
  • cd ios-webkit-debug-proxy
  • ./autogen.sh
  • 制作
  • sudo make install(安装在/usr/local/bin/ios_webkit_debug_proxy)