修改人员数量
This commit is contained in:
@@ -5,16 +5,25 @@ class FieldName {
|
||||
val defaultValue: String
|
||||
val type: FieldType
|
||||
|
||||
constructor(fieldName: String, hintText: String, defaultValue: String, type: FieldType = FieldType.TEXT){
|
||||
val fieldFindBy: FieldFindBy
|
||||
|
||||
constructor(fieldName: String, hintText: String, defaultValue: String, type: FieldType = FieldType.TEXT, fieldFindBy: FieldFindBy = FieldFindBy.HINT){
|
||||
this.fieldName = fieldName
|
||||
this.hintText = hintText
|
||||
this.defaultValue = defaultValue
|
||||
this.type = type
|
||||
this.fieldFindBy = fieldFindBy
|
||||
}
|
||||
val fieldName: String
|
||||
val hintText: String
|
||||
}
|
||||
|
||||
enum class FieldFindBy {
|
||||
TEXT,
|
||||
HINT,
|
||||
CONTENT_DESCRIPTION
|
||||
}
|
||||
|
||||
enum class FieldType {
|
||||
TEXT,
|
||||
SELECT,
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.loveerror.bested.tool.RootNodeCallback
|
||||
|
||||
class NormalGroupCreateForm(private val rootNodeCallback: RootNodeCallback) {
|
||||
|
||||
fun getRootInActiveWindow(): AccessibilityNodeInfo? {
|
||||
fun getRootInActiveWindow(): AccessibilityNodeInfo {
|
||||
return rootNodeCallback.getRootNodeReceived()
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class NormalGroupCreateForm(private val rootNodeCallback: RootNodeCallback) {
|
||||
fields.add(FieldName("法人代表", "请输入法人姓名", "", FieldType.TEXT))
|
||||
fields.add(FieldName("证件地址", "请输入证件地址", "", FieldType.TEXT))
|
||||
fields.add(FieldName("联系电话", "请输入联系电话", "13266667777", FieldType.TEXT))
|
||||
fields.add(FieldName("员工数", "请输入人数", "1", FieldType.TEXT))
|
||||
fields.add(FieldName("员工数", "请输入人数", "1", FieldType.TEXT, fieldFindBy= FieldFindBy.TEXT))
|
||||
|
||||
// select
|
||||
fields.add(FieldName("集团状态", "", "潜在集团", FieldType.SELECT))
|
||||
@@ -54,10 +54,18 @@ class NormalGroupCreateForm(private val rootNodeCallback: RootNodeCallback) {
|
||||
convertedMap[mappedKey] = value
|
||||
}
|
||||
convertedMap["证件名称"]= convertedMap["集团名称"].toString()
|
||||
|
||||
// 参保人数值如果为 eg: 8人 ->8
|
||||
if (convertedMap["员工数"]?.contains("人") == true) {
|
||||
// 处理 "2人 (2024年报)" 格式,提取数字部分
|
||||
val regex = Regex("(\\d+)人")
|
||||
val matchResult = regex.find(convertedMap["员工数"].toString())
|
||||
if (matchResult != null) {
|
||||
convertedMap["员工数"] = matchResult.groupValues[1]
|
||||
} else {
|
||||
convertedMap["员工数"] = convertedMap["员工数"]?.replace("人", "").toString()
|
||||
}
|
||||
}
|
||||
return convertedMap
|
||||
}
|
||||
|
||||
@@ -147,11 +155,17 @@ class NormalGroupCreateForm(private val rootNodeCallback: RootNodeCallback) {
|
||||
field.hintText, fieldMap[field.fieldName] ?: field.defaultValue
|
||||
)
|
||||
} else {
|
||||
if (field.fieldFindBy == FieldFindBy.TEXT) {
|
||||
AccessibilityTool.fillEditTextByText(root, fieldMap[field.fieldName] ?: field.defaultValue, field.fieldName,
|
||||
field.hintText)
|
||||
}else{
|
||||
AccessibilityTool.fillEditTextByHintText(
|
||||
root, fieldMap[field.fieldName] ?: field.defaultValue, field.fieldName,
|
||||
field.hintText
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
AccessibilityTool.printViewTree(
|
||||
@@ -185,11 +199,11 @@ class NormalGroupCreateForm(private val rootNodeCallback: RootNodeCallback) {
|
||||
AccessibilityTool.fillEditText(peopleCountNode, fieldMap["员工数"] ?: "1", "员工数")
|
||||
// fillEditTextByHintText(rootNew,fieldMap["员工数"] ?: "1", "员工数", "请输入人数")
|
||||
|
||||
// clickToOpenBottomSheetAddress(
|
||||
// root,
|
||||
// "请点击此处打点",
|
||||
// "浙江省杭州市余杭区高顺路8号五常西溪软件园金牛座A座"
|
||||
// )
|
||||
clickToOpenBottomSheetAddress(
|
||||
root,
|
||||
"请点击此处打点",
|
||||
"浙江省杭州市余杭区高顺路8号五常西溪软件园金牛座A座"
|
||||
)
|
||||
// 示例:点击"集团状态"触发底部选择,选择"在网集团"
|
||||
// fillCompanyNameField(root, groupName)
|
||||
|
||||
@@ -219,7 +233,7 @@ class NormalGroupCreateForm(private val rootNodeCallback: RootNodeCallback) {
|
||||
return
|
||||
}
|
||||
|
||||
Thread.sleep(3000)
|
||||
Thread.sleep(8000)
|
||||
// 地图选址 按钮
|
||||
val mapSearchButton = NodeToolText.findNodeByText(getRootInActiveWindow(), "地图选址")
|
||||
if (mapSearchButton != null) {
|
||||
@@ -229,14 +243,14 @@ class NormalGroupCreateForm(private val rootNodeCallback: RootNodeCallback) {
|
||||
println("未找到地图选址按钮")
|
||||
return
|
||||
}
|
||||
Thread.sleep(3000)
|
||||
Thread.sleep(5000)
|
||||
var clickFirst = findTargetElement(getRootInActiveWindow())
|
||||
if (clickFirst == null) {
|
||||
println("clickFirst is null")
|
||||
return
|
||||
}
|
||||
AccessibilityTool.performClick(clickFirst)
|
||||
Thread.sleep(3000)
|
||||
Thread.sleep(5000)
|
||||
|
||||
var searchButton = NodeToolText.findNodeByText(getRootInActiveWindow(), "搜索")
|
||||
if (searchButton == null) {
|
||||
|
||||
@@ -13,6 +13,11 @@ class AccessibilityTool {
|
||||
fillEditText(editTextNode,value,fieldName)
|
||||
}
|
||||
|
||||
fun fillEditTextByText(root: AccessibilityNodeInfo, value: String, fieldName : String, hintText: String) {
|
||||
val editTextNode = NodeToolText.findNodeByText(root, hintText)
|
||||
fillEditText(editTextNode,value,fieldName)
|
||||
}
|
||||
|
||||
fun fillEditText(editText: AccessibilityNodeInfo?, value: String, fieldName : String) {
|
||||
if (editText == null) {
|
||||
return
|
||||
@@ -84,7 +89,7 @@ class AccessibilityTool {
|
||||
println("已选择第一个搜索结果")
|
||||
|
||||
// 点击确认按钮
|
||||
Thread.sleep(500)
|
||||
Thread.sleep(3000)
|
||||
val confirmButton = NodeToolText.findNodeByText(root, "确认")
|
||||
?: NodeToolText.findNodeByText(root, "确定")
|
||||
if (confirmButton?.isClickable == true) {
|
||||
@@ -113,7 +118,7 @@ class AccessibilityTool {
|
||||
clickToOpenBottomSheet(rootNodeCallback.getRootNodeReceived(), fieldName)
|
||||
|
||||
// 2. 等待对话框完全显示
|
||||
Thread.sleep(1000)
|
||||
Thread.sleep(5000)
|
||||
|
||||
NodeToolTime.selectDateWithRetry(rootNodeCallback, year, month, day)
|
||||
}
|
||||
@@ -136,22 +141,18 @@ class AccessibilityTool {
|
||||
}
|
||||
|
||||
fun performBottomSheetSelection(rootNodeCallback: RootNodeCallback, triggerText: String, optionText: String) {
|
||||
val root = rootNodeCallback.getRootNodeReceived()
|
||||
if(root == null){
|
||||
return
|
||||
}
|
||||
// 1. 点击触发元素打开底部对话框
|
||||
clickToOpenBottomSheet(root, triggerText)
|
||||
clickToOpenBottomSheet(rootNodeCallback.getRootNodeReceived(), triggerText)
|
||||
|
||||
// 2. 等待对话框完全显示
|
||||
Thread.sleep(1000)
|
||||
Thread.sleep(4000)
|
||||
|
||||
// 3. 选择目标选项
|
||||
selectOptionFromBottomSheet(rootNodeCallback,optionText)
|
||||
|
||||
// 4. 明确点击确认按钮 dubbo check
|
||||
clickConfirmButton(rootNodeCallback)
|
||||
Thread.sleep(500) // 等待确认操作完成
|
||||
Thread.sleep(1500) // 等待确认操作完成
|
||||
}
|
||||
|
||||
// 点击可点击的触发元素来显示底部选择对话框
|
||||
@@ -182,9 +183,6 @@ class AccessibilityTool {
|
||||
fun selectOptionFromBottomSheet(rootNodeCallback: RootNodeCallback,optionText: String, confirm: Boolean = true) {
|
||||
// 获取更新后的根节点
|
||||
val newRoot = rootNodeCallback.getRootNodeReceived()
|
||||
if (newRoot == null) {
|
||||
return
|
||||
}
|
||||
|
||||
// 查找并点击选项
|
||||
val optionNode = NodeToolText.findNodeByText(newRoot, optionText)
|
||||
@@ -204,6 +202,7 @@ class AccessibilityTool {
|
||||
} else {
|
||||
println("未找到底部选项: $optionText")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user