且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Python 中以编程方式启动 appium 服务器

更新时间:2023-08-24 13:24:34

首先,手动检查 shell 上的appium"命令是否启动 appium 服务器很好(在您的情况下它工作正常).就我而言,这与安装 Appium 桌面版无关.发布我为解决此问题所做的详细信息,以防它对某人有所帮助:

First of all its good to check manually if "appium" command on shell launches the appium server or not(Seems in your case its working fine). In my case it was not with the installation of Appium desktop version. Posting the details of what i did to resolve this in case it helps someone:

  1. 已安装 npm(作为 node 安装的一部分,MSI 在 nodejs.org 上可用)
  2. npm install -g appium
  1. Installed npm (as part of node installation, MSI available at nodejs.org)
  2. npm install -g appium

现在回答您的主要问题,下面是我在 Python 脚本中使用的内容,用于在新窗口上启动 appium 服务器,以便它与脚本执行的其余部分分开运行:

Now to answer your main question, below is what i used in my Python script to start the appium server on a new window so that it runs separately from the rest of the script execution:

import os
os.system("start /B start cmd.exe @cmd /k appium") 

如果您想更改 appium 服务器的端口(例如更改为 4728)(可能是当您有多个服务器用于多个设备时),您可以使用以下内容:

In case you want to change the port(e.g. to 4728) of the appium server (may be when you have multiple servers for multiple devices) you can use following:

os.system("start /B start cmd.exe @cmd /k appium -a 127.0.0.1 -p 4728")