#coding=utf-8 #author='Shichao-Dong' import time, os from appium import webdriver from comm.Log import Logger from selenium.common.exceptions import WebDriverException from comm.StartAppiumServer import Sp from comm.readConfig import ReadConfig conf = ReadConfig() log = Logger() app_path = os.path.join(os.path.abspath(os.path.join(os.getcwd(), "../..")), 'UI-Test', 'comm', 'apps', 'cibn.apk') platformName = conf.get_config('platformName') appPackage = conf.get_config('appPackage') appActivity = conf.get_config('appActivity') appium_port = conf.get_config('appium_port') class webDriver: def __init__(self): self.get_device = conf.get_cmd('viewDevices') self.get_Version = conf.get_cmd('platformVersion') self.startServer = conf.get_cmd('startServer') def get_deviceName(self): values = os.popen(self.get_device).readlines() print(values) dev = values[1].split()[0]
#!/usr/bin/env python # -*- coding:utf-8 -*- #@Time : 2019/9/3 16:57 #@Author: dongyani from comm.Log import Logger from comm.readConfig import ReadConfig import time, os conf = ReadConfig() log = Logger() appium_port = conf.get_config('appium_port') class Sp(): def stop_appium(self): '''关闭appium服务''' # if pc.upper() == 'WIN': p = os.popen(f'netstat -aon|findstr {appium_port}') p0 = p.read().strip() print(f"appium进程信息:{p0}") if p0 != '' and 'LISTENING' in p0: p1 = int(p0.split('LISTENING')[1].strip()[0:4]) # 获取进程号 # print(p1) os.popen(f'taskkill /F /PID {p1}') # 结束进程 print('appium server进程已结束') # elif pc.upper() == 'MAC': # p = os.popen(f'lsof -i tcp:{post_num}') # p0 = p.read() # if p0.strip() != '': # p1 = int(p0.split('\n')[1].split()[1]) # 获取进程号