|
@@ -1,5 +1,6 @@
|
|
|
# -*- coding:utf-8 -*-
|
|
|
import os
|
|
|
+from enum import Enum
|
|
|
from BaseLog import CBaseLog
|
|
|
from ExtraData import CExtraData
|
|
|
from OptionExcel import COptionExcel
|
|
@@ -44,6 +45,13 @@ def strSplit(text):
|
|
|
return ret
|
|
|
|
|
|
|
|
|
+# 枚举:value类型
|
|
|
+class VType(Enum):
|
|
|
+ SelectType = 0
|
|
|
+ InputType = 1
|
|
|
+ RangeType = 2
|
|
|
+
|
|
|
+
|
|
|
# 注意:所有不对外暴露的变量和函数需要私有化,以明确哪些接口和参数是对外的。
|
|
|
# 这样便于后期维护时,根据对外的变量和函数来做处理。
|
|
|
class COptionAction(CBaseLog):
|
|
@@ -83,6 +91,9 @@ class COptionAction(CBaseLog):
|
|
|
self.__optionValueText = ""
|
|
|
# 获取一次当前层级信息;
|
|
|
self.getCurOptionInfo()
|
|
|
+ # 相关返回操作;
|
|
|
+ self.__isEnterKeyInValue = False # 节点在value表时,是否发送enter key.
|
|
|
+ self.__valueType = VType.SelectType # 节点在value表时,value值的类型(0:选择型, 1:输入型,2:range()数值型。)
|
|
|
|
|
|
@property
|
|
|
def pos(self):
|
|
@@ -105,6 +116,7 @@ class COptionAction(CBaseLog):
|
|
|
参数:无
|
|
|
返回:截图路径;
|
|
|
'''
|
|
|
+
|
|
|
def takePicture(self):
|
|
|
img = os.path.join(getSATTmpDIR(), "menutree_runpath.png")
|
|
|
COptionAction.__ccard.takePicture(img)
|
|
@@ -145,6 +157,7 @@ class COptionAction(CBaseLog):
|
|
|
参数:
|
|
|
返回:
|
|
|
'''
|
|
|
+
|
|
|
def inputUnlock(self, stdText, password=''):
|
|
|
# 如果锁住,按ok会弹出输入密码框;
|
|
|
self.sendKey("ok")
|
|
@@ -182,6 +195,7 @@ class COptionAction(CBaseLog):
|
|
|
|
|
|
注意:对应以前的dealOthers函数。
|
|
|
'''
|
|
|
+
|
|
|
def dealPasswordBox(self):
|
|
|
parentOption = ''
|
|
|
if self.isOnValueSheet():
|
|
@@ -259,7 +273,7 @@ class COptionAction(CBaseLog):
|
|
|
# 析出参数;
|
|
|
if isValueSheet:
|
|
|
curLevel = 'value'
|
|
|
- curParent = self.__optionPaths[g_level[self.__pos-1]]['parent']
|
|
|
+ curParent = self.__optionPaths[g_level[self.__pos - 1]]['parent']
|
|
|
curOption = self.__optionValueInfo['option']
|
|
|
curOthers = self.__optionValueInfo['others']
|
|
|
else:
|
|
@@ -307,7 +321,8 @@ class COptionAction(CBaseLog):
|
|
|
ocrThreshold, curOthers['marquee'],
|
|
|
isNumberText, isValueSheet)
|
|
|
else:
|
|
|
- return self.__getStaticPicText(self.takePicture(), curOption, optionTextList, siblingTextList, ocrConfigList,
|
|
|
+ return self.__getStaticPicText(self.takePicture(), curOption, optionTextList, siblingTextList,
|
|
|
+ ocrConfigList,
|
|
|
ocrThreshold,
|
|
|
isNumberText, isValueSheet)
|
|
|
# endif
|
|
@@ -318,6 +333,7 @@ class COptionAction(CBaseLog):
|
|
|
返回:Boolean.
|
|
|
|
|
|
'''
|
|
|
+
|
|
|
def isOnTargetOption(self):
|
|
|
return True if self.__pos == (self.__optionPaths.__len__() - 1) else False
|
|
|
|
|
@@ -403,6 +419,25 @@ class COptionAction(CBaseLog):
|
|
|
backKey = self.__curOptionInfo['back_key']
|
|
|
else:
|
|
|
backKey = self.__optionValueInfo['back_key']
|
|
|
+ # 同时,根据是否有发送enter key和值类型来判断是否需要多发次返回。
|
|
|
+ if not self.__isEnterKeyInValue:
|
|
|
+ # 标记为True,防止重复进入.
|
|
|
+ self.__isEnterKeyInValue = True
|
|
|
+ self.info(u"进入了value表但未按enter key, 值类型=%s" % str(self.__valueType))
|
|
|
+ if self.__valueType == VType.SelectType:
|
|
|
+ # 如果是选择型数据,没有enter键;
|
|
|
+ self.back2ParentNode(False)
|
|
|
+ elif self.__valueType == VType.InputType:
|
|
|
+ pass
|
|
|
+ # 如果是输入型数据,没有enter键;
|
|
|
+ # 可能输入后,自动进入。需要根据autoBackFlag来判断;
|
|
|
+ # if autoBackFlag is False:
|
|
|
+ # self.back2ParentNode(False)
|
|
|
+ # else:
|
|
|
+ # self.__pos -= 1
|
|
|
+ elif self.__valueType == VType.RangeType:
|
|
|
+ # 如果是进度条数据,没有enter键;
|
|
|
+ self.back2ParentNode(False)
|
|
|
|
|
|
if backKey.__len__() == 0:
|
|
|
self.sendKey('return', 1, 1)
|
|
@@ -446,6 +481,7 @@ class COptionAction(CBaseLog):
|
|
|
|
|
|
a移动到p4上,完成了v1设置后,a.back2ParentNode()后,此时如果要操作b并设置v2,就要b.SetCurPos(a.pos).
|
|
|
'''
|
|
|
+
|
|
|
def setCurPos(self, pos):
|
|
|
if pos < 0 or pos > self.__optionPaths.__len__():
|
|
|
self.error(u"pos值[%d]超出路径范围:[0-%d]" % (pos, self.__optionPaths.__len__()))
|
|
@@ -486,14 +522,14 @@ class COptionAction(CBaseLog):
|
|
|
# 0 表示默认选择类型.
|
|
|
# 1 表示输入类型(有些输入完了,正确值会自动进入).
|
|
|
# 2 表示进度条数据型.
|
|
|
- valueType = 0
|
|
|
+ self.__valueType = VType.SelectType
|
|
|
# 是否为数字文本(特指:range(0, 100));
|
|
|
isNumberText = self.isNumberText(valueText)
|
|
|
# 数值型value;
|
|
|
if isNumberText:
|
|
|
if moveKey[0] == 'input':
|
|
|
# 标记值类型;
|
|
|
- valueType = 1
|
|
|
+ self.__valueType = VType.InputType
|
|
|
# 将数值转成字符;
|
|
|
optionValue = self.__optionValue
|
|
|
if type(optionValue) == int or type(optionValue) == float:
|
|
@@ -503,14 +539,14 @@ class COptionAction(CBaseLog):
|
|
|
self.sendKey(chList, 1, duration)
|
|
|
else:
|
|
|
# 标记值类型;
|
|
|
- valueType = 2
|
|
|
+ self.__valueType = VType.RangeType
|
|
|
# 相差值;
|
|
|
num = int(self.__optionValue) - int(self.__optionValueText)
|
|
|
# 正->往右或下,负->往左或上;
|
|
|
self.sendKey(moveKey[1] if num > 0 else moveKey[0], abs(num), duration)
|
|
|
elif moveKey[0] == 'input':
|
|
|
# 标记值类型;
|
|
|
- valueType = 1
|
|
|
+ self.__valueType = VType.InputType
|
|
|
# 将字符转成list;
|
|
|
chList = list(self.__optionValue)
|
|
|
self.sendKey(chList, 1, duration)
|
|
@@ -519,24 +555,10 @@ class COptionAction(CBaseLog):
|
|
|
if enterKey != 'default':
|
|
|
self.info(u"value节点具有enter key")
|
|
|
self.sendKey(enterKey, 1, 0.1)
|
|
|
+ self.__isEnterKeyInValue = True
|
|
|
# enter之后,可能会返回上层菜单,也可能不返回.
|
|
|
# if autoBackFlag is False:
|
|
|
# self.back2ParentNode(False)
|
|
|
- else:
|
|
|
- if valueType == 0:
|
|
|
- # 如果是选择型数据,没有enter键;
|
|
|
- self.back2ParentNode(False)
|
|
|
- elif valueType == 1:
|
|
|
- pass
|
|
|
- # 如果是输入型数据,没有enter键;
|
|
|
- # 可能输入后,自动进入。需要根据autoBackFlag来判断;
|
|
|
- # if autoBackFlag is False:
|
|
|
- # self.back2ParentNode(False)
|
|
|
- # else:
|
|
|
- # self.__pos -= 1
|
|
|
- elif valueType == 2:
|
|
|
- # 如果是进度条数据,没有enter键;
|
|
|
- self.back2ParentNode(False)
|
|
|
|
|
|
'''
|
|
|
函数:获取当前层级的目标option详细信息.
|
|
@@ -569,6 +591,7 @@ class COptionAction(CBaseLog):
|
|
|
参数:无
|
|
|
返回:Boolean, 检测正常返回True
|
|
|
'''
|
|
|
+
|
|
|
def checkRunOptionPath(self):
|
|
|
outData = self.__optionExcel.checkOptionPaths(self.__optionPaths)
|
|
|
if str(outData[1]) == 'NoExit':
|
|
@@ -587,6 +610,7 @@ class COptionAction(CBaseLog):
|
|
|
textList value_for_ocr或option_for_ocr数组
|
|
|
返回:Boolean, 如果是range(xx,xx)类型返回True.
|
|
|
'''
|
|
|
+
|
|
|
def isNumberText(self, textList):
|
|
|
# 是否获取数值文本;
|
|
|
isNumberText = False
|
|
@@ -840,6 +864,7 @@ class COptionAction(CBaseLog):
|
|
|
参数:
|
|
|
返回:
|
|
|
'''
|
|
|
+
|
|
|
def getPathLength(self):
|
|
|
if self.__optionPaths is None:
|
|
|
self.error(u"路径空,返回0")
|