问题
I am a newbie to Python and have created simple Appium Automation Test case for Android mobile app.
I have setup Jenkins server and want to run Appium on it so there are 2 ways:
- Run appium server via Jenkins (We can run it using
appium
command but when I run appium command it just "hangs up" and showing server console continiously) - Start Appium Server programmatically using Python
I know we can run Appium Server programmatically using Java but don't know about python.
So, if you have any idea about either of above 2 ways, please post the answer.
Thank you
回答1:
I have found the answer for 1:
Use appium &
command.
Use & at the end of the command that will run it in background and didn't freeze the terminal.
Please Refer this
回答2:
Below is what you can do for 2. Start Appium Server programmatically using Python
import os
#starts appium on same terminal window
os.system("appium")
#starts appium on new terminal window
os.system("start /B start cmd.exe @cmd /k appium")
回答3:
The way I do it is:
write appium
in terminal
or if I want a specific chromedriver version then I do:
appium --chromedriver-executable /path/to/my/chromedriver/chromedriver_2.42
回答4:
1) Create a shell script called startAppium.sh with this command: appium --debug &
2) Create a shell script called killAppium.sh with this command: kill $(ps -e | grep 'appium' | awk '{print $1}')
3) Use python to run either process to execute the shell scripts: import killProcess killProcess.call(['./killAppium.sh'])
Note: I use the above for Jenkins CI/CD in the groovy file's setup and post blocks with just the commands, i.e: sh "appium --debug &" and sh "kill $(ps -e | grep 'appium' | awk '{print $1}')".
来源:https://stackoverflow.com/questions/50131893/how-to-start-and-stop-appium-server-programmatically-using-python