feat 前面步骤中提取的参数,需要支持在后续步骤中引用
This commit is contained in:
@@ -44,6 +44,9 @@ import org.springframework.util.CollectionUtils;
|
||||
@Slf4j
|
||||
public class UiSceneStepsServiceImpl implements IUiSceneStepsService {
|
||||
|
||||
// 添加静态Map用于存储提取的数据
|
||||
private static final Map<String, Object> extractedDataMap = new HashMap<>();
|
||||
|
||||
@Resource
|
||||
private UiSceneStepsMapper uiSceneStepsMapper;
|
||||
@Resource
|
||||
@@ -404,6 +407,8 @@ public class UiSceneStepsServiceImpl implements IUiSceneStepsService {
|
||||
Map<String, Object> beforeData = CollectionUtils.isEmpty(beforeSettingList)
|
||||
? new HashMap<>()
|
||||
: filterBydataExtractionQOList(beforeSettingList, seleniumUtils);
|
||||
// 保存前置数据到Map中
|
||||
extractedDataMap.put("beforeData", beforeData);
|
||||
//后置操作设置
|
||||
List<UiHighSettingVO> afterSettingList = extractafterSetting(uiHighSettingVOList);
|
||||
|
||||
@@ -457,6 +462,8 @@ public class UiSceneStepsServiceImpl implements IUiSceneStepsService {
|
||||
Map<String, Object> afterData = CollectionUtils.isEmpty(afterSettingList)
|
||||
? new HashMap<>()
|
||||
: filterBydataExtractionQOList(afterSettingList, seleniumUtils);
|
||||
// 保存后置数据到Map中
|
||||
extractedDataMap.put("afterData", afterData);
|
||||
Map<String, Object> mergedData = new HashMap<>();
|
||||
if (!beforeData.isEmpty()) {
|
||||
mergedData.put("前置数据提取", beforeData);
|
||||
@@ -1538,6 +1545,27 @@ public class UiSceneStepsServiceImpl implements IUiSceneStepsService {
|
||||
seleniumUtils.clearInput(locator);
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查输入值是否是变量引用格式 ${key}
|
||||
if (inputValue.startsWith("${") && inputValue.endsWith("}")) {
|
||||
// 从Map中获取前置和后置操作的数据集合
|
||||
Map<String, Object> beforeData = (Map<String, Object>) extractedDataMap.get("beforeData");
|
||||
Map<String, Object> afterData = (Map<String, Object>) extractedDataMap.get("afterData");
|
||||
|
||||
// 先从前置数据中查找,如果没有再从后置数据中查找
|
||||
Object value = beforeData != null ? beforeData.get(inputValue) : null;
|
||||
if (value == null && afterData != null) {
|
||||
value = afterData.get(inputValue);
|
||||
}
|
||||
|
||||
if (value != null) {
|
||||
inputValue = value.toString();
|
||||
log.info("变量 {} 被替换为: {}", inputValue, value);
|
||||
} else {
|
||||
log.warn("未找到变量 {} 的值,保持原样", inputValue);
|
||||
}
|
||||
}
|
||||
|
||||
// 执行输入操作
|
||||
if (step.getOperate() == 1) { // 普通输入框
|
||||
seleniumUtils.inputText(
|
||||
|
||||
@@ -469,10 +469,10 @@
|
||||
<el-option key="11" label="元素文本不包含期望(NotInText)" value="11"></el-option>
|
||||
</el-select>
|
||||
<div style="display: flex; align-items: center; width: 100%;">
|
||||
<el-input
|
||||
v-model="content.expectations"
|
||||
placeholder="请输入期望值"
|
||||
class="select"
|
||||
<el-input
|
||||
v-model="content.expectations"
|
||||
placeholder="请输入期望值"
|
||||
class="select"
|
||||
:disabled="['1','2','3','4','5','6'].includes(content.assertionMode)"
|
||||
style="flex: 1;">
|
||||
</el-input>
|
||||
@@ -586,7 +586,7 @@
|
||||
<el-option :key="2" label="出现异常截图" :value="2"></el-option>
|
||||
<el-option :key="3" label="不截图" :value="3"></el-option>
|
||||
</el-select>
|
||||
<el-tooltip class="item" effect="dark" content="当前步骤截图: 场景步骤执行后截图,步骤如果触发原生弹窗(alert或prompt),或不存在页面时,截图不生效;出现异常截图:
|
||||
<el-tooltip class="item" effect="dark" content="当前步骤截图: 场景步骤执行后截图,步骤如果触发原生弹窗(alert或prompt),或不存在页面时,截图不生效;出现异常截图:
|
||||
当前步骤出现异常截图,包括场景步骤异常、数据提取和断言异常;
|
||||
不截图: 当前场景步骤不截图。" placement="right">
|
||||
<i class="el-icon-info" style="margin-left: 20px;"></i>
|
||||
@@ -611,7 +611,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
activeName: 'first',
|
||||
uiHighSettingVOList: [], //
|
||||
uiHighSettingVOList: [], //
|
||||
saveForm: {
|
||||
errorHandling: '1', // 错误处理
|
||||
waitElementTime: 15000, // 等待元素超时时间
|
||||
@@ -630,7 +630,6 @@ export default {
|
||||
pageSize: 10,
|
||||
name: null,
|
||||
},
|
||||
elementList: [],
|
||||
total: 0,
|
||||
editForm: {
|
||||
name: null, // 元素名称
|
||||
@@ -641,7 +640,6 @@ export default {
|
||||
},
|
||||
dialogTitle: '',
|
||||
dialogVisible: false,
|
||||
groupList: [], // 分组
|
||||
typeList: ['id', 'name', 'className', 'tagName', 'linkText', 'partialLinkText', 'css', 'xpath', 'lable', 'value', 'index'],
|
||||
rules: {
|
||||
name: [{ required: true, message: '请输入元素名称', trigger: 'blur' }],
|
||||
@@ -658,7 +656,7 @@ export default {
|
||||
this.getElementData()
|
||||
},
|
||||
methods: {
|
||||
//
|
||||
//
|
||||
getGroupListData() {
|
||||
listGroup('element').then(res => {
|
||||
if (res.code === 200) {
|
||||
@@ -947,11 +945,11 @@ export default {
|
||||
// 获取元素列表
|
||||
getElementListData(groupId, target) {
|
||||
if (!groupId) return;
|
||||
|
||||
|
||||
getElementList({ groupId: groupId }).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.elementList = res.rows;
|
||||
|
||||
|
||||
// 检查当前选中的operateElementId是否在新的列表中存在
|
||||
if (target && target.operateElementId) {
|
||||
const elementExists = this.elementList.some(item => item.id === target.operateElementId);
|
||||
@@ -1025,7 +1023,7 @@ export default {
|
||||
} else {
|
||||
this.activeName = 'second'
|
||||
}
|
||||
|
||||
|
||||
// 如果有已存在的设置,则加载它们
|
||||
if (newVal.uiHighSettingVOList != null) {
|
||||
this.uiHighSettingVOList = newVal.uiHighSettingVOList
|
||||
@@ -1043,7 +1041,7 @@ export default {
|
||||
case '3':
|
||||
this.saveForm.errorHandling = item.errorHandling
|
||||
break
|
||||
// 其他设置
|
||||
// 其他设置
|
||||
case '4':
|
||||
if (item.otherSettingsQO != null) {
|
||||
this.saveForm.waitElementTime = item.otherSettingsQO.waitElementTime || 15000
|
||||
@@ -1234,7 +1232,7 @@ export default {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
|
||||
|
||||
.select {
|
||||
min-width: 200px;
|
||||
}
|
||||
@@ -1267,7 +1265,7 @@ export default {
|
||||
|
||||
.information {
|
||||
margin-top: 20px;
|
||||
|
||||
|
||||
> div:first-child {
|
||||
font-weight: bold;
|
||||
margin-bottom: 10px;
|
||||
|
||||
Reference in New Issue
Block a user