appmw

Posted liuyun66535309

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了appmw相关的知识,希望对你有一定的参考价值。

# coding:utf-8

from appiumServer import AppiumServer
from stfConnect import stfConnect
from adbCom import adbCommand
import time,os

def startAppium(connName,taskTempDir):
    s=AppiumServer(connName,taskTempDir)
    appiumUrl,errorMsg = s.start_appium() 
    port = s.get_port()
    return appiumUrl,errorMsg ,port
    
def shutDownAppium(port):
    #print "start..."
    process = os.popen("netstat -aon |findstr %d" % port).read()
    pid = process.replace(  ,‘‘).split(" ")[2]
    print(pid)
    m = os.popen("taskkill -f -pid %s" % pid)
    print(m.read())
    
def getandroidVersion(devicename):
    adbconn = adbCommand(devicename,devicename)
    return adbconn.getAndroidVersion()
    
def stfDeviceConnect(ip,port,stfToken,devicename):    
    s = stfConnect(ip,port,stfToken,devicename)
    s.deleteDevice()
    time.sleep(0.5)
    s.addDevice()
    time.sleep(0.5)
    #print s.connectName
    stfConn = s.getAdbConnectName()
    print stfConn
    adbConn = adbCommand(connName=stfConn,devicename=devicename)
    result = adbConn.connect_Terminate()
    termVersion = adbConn.getAndroidVersion()
    print termVersion
    return stfConn,termVersion,result

def stfDeviceDisConnect(ip,port,stfToken,devicename):
    s = stfConnect(ip,port,stfToken,devicename)
    s.deleteDevice()    
    
def touch(devicename,dx, dy):
    """
    usage: touch(500, 500)
    """
    os.popen("adb -s "+devicename+" shell input tap " + str(dx) + " " + str(dy))
    time.sleep(0.5)
    
def SetAppiumIme(connName):
    os.system(adb -s +connName+ shell ime set io.appium.android.ime/.UnicodeIME)
    #print(‘SetUnicodeIME‘)
    
def SetSougouIme(connName):
    os.system(adb  -s +connName+ shell ime set com.sohu.inputmethod.sogou/.SogouIME)
    #print(‘SetSogouIME‘)

if __name__=="__main__":
    ‘‘‘ip = "192.168.14.236"
    port = 7100
    devicename = "K11TJ64050000013"
    #stfToken = "bbb4c9743b6e4552b94b589436d377f5442a58bfff4146eb8de5c088f445ccd6"  #李江洪机器
    stfToken = "1826a9a9c8414665bffc4eba538cc18287fd26b824be4d349164d7b8d2ef7aaf" #该token在88.9服务器生成的    
    print ‘stf device connect...‘
    connName,termVersion,result = stfDeviceConnect(ip,port,stfToken,devicename)
    print ‘connecting appium...‘
    appium_server_url,erromessage,appiumPort = startAppium(connName,‘E:‘)
    time.sleep(20)
    print ‘stop Appium ...‘
    shutDownAppium(appiumPort) 
    print ‘disconnect device...‘
    stfDeviceDisConnect(ip,port,stfToken,devicename)
    #touch(‘192.168.12.236:7401‘,50,300)‘‘‘
    print getandroidVersion(K15VY68180013445)
    
 

 

以上是关于appmw的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数