简体   繁体   中英

How to start appium server from my python code with AppiumService()?

I am running some test on real Android device. I installed APpium server via pm. I can run Appium server with Windows command line 'appium'.

I try to start the appium server from my python code with these lines of code:

appium_service = AppiumService()
appium_service.start()

but nothing happened, I don't get any output, no error message, no exception. nothing.

So I tried again by passing some parameters:

appium_service = AppiumService()
appium_service.start(address='0.0.0.0', p='4723')

Again nothing happened!

It seems the code is waiting... or sleeping.... these lines of code are at the beginning of the script... I can see some logger messages for the initialization of my webdriver... but then nothing.

Is there anyone please who can help me to debug and to make run APpium server from my code without the command line os option.

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:

Installed npm (as part of node installation, MSI available at nodejs.org) npm install -g 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")

In case you want to change the port(eg 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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM