简体   繁体   中英

How to invoke the appium server via python

I am trying to start an appium server via a call to a python function at the start of my script.

I found the line I used to type into the windows command prompt was: appium --base-path /wd/hub --default-capabilities "{\"app\": \"myapp.app\"}"

This worked fine.

Therefore, I tried the following in python:

import subprocess

subprocess.Popen("""start appium --base-path /wd/hub --default-capabilities "{\"app\": \"myapp.app\"}"
""",shell=True)

This gives the following error: C:\Users\jainv\AppData\Roaming\npm\node_modules\appium\build\lib\main.js: error: argument -dc/--default-capabilities: invalid parseDefaultCaps value: '{app: myapp.app}'

It appears to be removing the "" around the capabilities dict and replacing them with single quotes instead. Why is this happening?

Try the following code

# --base-path has to give which is used to slove https://github.com/appium/appium/issues/15813
# [HTTP] no route found for /wd/hub/session
from appium.webdriver.appium_service import AppiumService
appium_service = AppiumService()
appium_service.start(args=["--base-path", "/wd/hub"])

Long keys did not work for me. What worked for me is

appium_service.start(args=['-pa', '/wd/hub'])

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