如何从MAC机器的命令提示符启动Appium服务器?
我使用appium自动化ios原生移动应用程序。 到现在为止,我通过单击启动button从Appium GUI启动服务器。 现在我想从命令提示符启动服务器。
我可以通过以下步骤在Windows机器上做同样的事情:
- 启动Node.js命令提示符
- 导航至Appium bin文件夹
- 使用命令
node appium
我遇到了如何在Mac上启动Node.js命令提示符的问题。 你能告诉我如何从Mac上的命令提示符启动Appium服务器。
如果你使用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
如果你想有额外的服务器标志,所有的都可以在他们的网站与文件。
要在MAC中启动appium,只需在terminal应用程序中input=> appium& 。 为了使上述命令起作用,您必须以terminal模式安装appium。 不过有两种方式,一种是使用HomeBrew,另一种是直接使用Node.js。 你可以在网上find安装HomeBrew的教程。 按照以下步骤直接使用node.js进行安装 –
- 转到https://nodejs.org/
- 在Mac中下载并安装最新的稳定版本的node.js软件包
- 现在打开terminal应用程序
- 运行以下命令=> npm install -g appium
- 这应该在您的系统中安装具有全局特权的Appium。 在安装完appium之后,你可以在同一个terminal窗口运行命令=> appium-doctor来validation是否安装正确。
- 如果所有内容都是绿色的,请运行=> appium启动appium服务器
希望这有助于。
/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
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();
正如其他答案指出的,如果你已经安装了Appium通过terminal,然后只需在terminal窗口键入appium &
启动appium服务器。 在这里你只需要知道如何通过terminal安装appium。
1.安装自制软件 。
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
你可以在这里find关于appium下载osx的指南。
试试这个以编程方式启动你的appium服务器的mac os,它包括自动化的webkitdebugging代理以及debugging所需要的。
//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(); }
打开terminal并input以下命令
appium --address 127.0.0.1 --port 4723
按回车,然后它将自己注册到127.0.0.1,并将听取4723端口。 您可以通过添加应用程序types等来扩展此命令
希望对你有帮助
干杯
对于任何正在使用npm(node / js / typescript)的人来说,我已经创build了一个名为appium-controller的模块,以编程方式(mac或windows)在后台启动和停止appium。 它可以通过节点调用方法或通过cli传入特定的端口。