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