import os
import urllib.request
from urllib.error import URLError
from multiprocessing import Process
import threading
# readConfigLocal = readConfig.ReadConfig()
class AppiumServer:
def __init__(self,openAppium, baseUrl):
# openAppium = "node D:\\app\Appium\\node_modules\\appium\\bin\\appium.js"
# baseUrl = "http://127.0.0.1:4723/wd/hub"
self.openAppium = openAppium
self.baseUrl = baseUrl
def start_server(self):
"""start the appium server
:return:
"""
t1 = RunServer(self.openAppium)
p = Process(target=t1.start())
p.start()
def stop_server(self):
"""stop the appium server
:return:
"""
# kill myServer
os.system('taskkill /f /im node.exe')
def re_start_server(self):
"""reStart the appium server
"""
self.stop_server()
self.start_server()
def is_runnnig(self):
"""Determine whether server is running
:return:True or False
"""
response = None
url = self.baseUrl+"/status"
try:
response = urllib.request.urlopen(url, timeout=5)
if str(response.getcode()).startswith("2"):
return True
else:
return False
except URLError:
return False
finally:
if response:
response.close()
class RunServer(threading.Thread):
def __init__(self, cmd):
threading.Thread.__init__(self)
self.cmd = cmd
def run(self):
os.system(self.cmd)
# if __name__ == "__main__":
# oo = AppiumServer()
# oo.start_server()
# print("strart server")
# print("running server")
# oo.stop_server()
# print("stop server")
代碼控制appium-server
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 我們可以在Appium官方網(wǎng)站上下載操作系統(tǒng)相應(yīng)的Appium版本。 https://bitbucket.org/...
- 這里分享外網(wǎng)一篇文章,對Appium UiAutomator2 Server的工作原理作了很詳細(xì)的介紹 原貼: H...
- 想并行運(yùn)行多個appium,效果圖: 下載selenium-server-standalone-xxx.jar 執(zhí)...
- Appium: adb server version (31) doesn't match this client...