fix:断言

This commit is contained in:
2025-05-26 11:18:23 +08:00
parent 441f7d041d
commit e7248e613a

View File

@@ -371,6 +371,183 @@
</el-collapse-item>
</el-collapse>
</div>
<!-- 断言 -->
<div v-if="item.operateType === '2'">
<el-collapse v-model="index" accordion>
<el-collapse-item name="1">
<template slot="title">
<div class="time">
<div class="time-left">
<div class="number">{{ index + 1 }}</div>
<div>断言</div>
<el-input v-model="item.name" class="select" @click.native.stop></el-input>
</div>
<div class="time-right">
<el-switch v-model="item.isDisabled" active-value="1" inactive-value="0"
@click.native.stop></el-switch>
<el-button type="text" icon="el-icon-delete" style="color: red;"
@click="afterDelete(index)"></el-button>
</div>
</div>
</template>
<div class="collapse-content">
<div style="margin-bottom: 20px;">判断实际结果是否与期望的一致可添加多条断言</div>
<el-select v-model="saveForm.assertionType" class="select">
<el-option key="1" label="弹窗文本" value="1"></el-option>
<el-option key="2" label="元素断言" value="2"></el-option>
<el-option key="3" label="下拉框" value="3"></el-option>
<el-option key="4" label="网页标题" value="4"></el-option>
</el-select>
<el-button type="primary" plain @click="addAfterAssionQOList(index)"
style="margin-left: 10px;">添加</el-button>
<!-- 弹窗文本 -->
<div v-if="item.assertionQOList.popupTexts.length > 0" class="information">
<div>弹窗文本</div>
<div v-for="(content, index2) in item.assertionQOList.popupTexts" class="time">
<div class="time-left">
<el-select v-model="content.isPopText">
<el-option key="1" label="是" value="1"></el-option>
<el-option key="2" label="否" value="2"></el-option>
</el-select>
<el-input v-model="content.expectations" placeholder="请输入期望弹窗文本"></el-input>
</div>
<div class="time-right">
<el-switch v-model="content.isDisabled" active-value="1" inactive-value="0"
@click.native.stop></el-switch>
<el-button type="text" icon="el-icon-delete" style="color: red;"
@click="deleteAssertion('1', index, index2)"></el-button>
</div>
</div>
</div>
<!-- 元素断言 -->
<div v-if="item.assertionQOList.elementAssertions.length > 0" class="information">
<div>元素断言</div>
<div v-for="(content, index2) in item.elementAssertions.popupTexts" class="time">
<div class="time-left">
<div class="operateObject-wrap">
<el-select v-model="content.operateObject" class="select">
<el-option key="1" label="元素对象" value="1"></el-option>
<el-option key="2" label="元素定位" value="2"></el-option>
</el-select>
<!-- 元素对象 -->
<div v-show="content.operateObject != '2'" class="operateObject-wrap">
<el-select v-model="content.operateGroupId" class="select" @change="getOperateGroup">
<el-option v-for="item in groupList" :key="item.id" :label="item.name"
:value="item.id"></el-option>
</el-select>
<el-select v-model="content.operateElementId" class="select">
<el-option v-for="item in elementList" :key="item.id" :label="item.name"
:value="item.id"></el-option>
</el-select>
</div>
<!-- 元素定位 -->
<div v-show="content.operateObject === '2'" class="operateObject-wrap">
<el-select v-model="content.operateLocType" class="select" @change="getOperateLoc">
<el-option v-for="item in groupList" :key="item.id" :label="item.name"
:value="item.id"></el-option>
</el-select>
<el-select v-model="content.operateLocValue" class="select">
<el-option v-for="item in elementList" :key="item.id" :label="item.name"
:value="item.id"></el-option>
</el-select>
</div>
</div>
</div>
<div class="time-right">
<el-switch v-model="content.isDisabled" active-value="1" inactive-value="0"
@click.native.stop></el-switch>
<el-button type="text" icon="el-icon-delete" style="color: red;"
@click="deleteAssertion('2', index, index2)"></el-button>
</div>
<div class="time-left">
<el-select v-model="content.assertionMode">
<el-option key="1" lable="元素被选中(Checked)" value="1"></el-option>
<el-option key="2" lable="元素可编辑(Editable)" value="2"></el-option>
<el-option key="3" lable="元素存在(ElementPresent)" value="3"></el-option>
<el-option key="4" lable="元素不存在(ElementNotPresent)" value="4"></el-option>
<el-option key="5" lable="元素未被选中(NotChecked)" value="5"></el-option>
<el-option key="6" lable="元素不可编辑(NotEditable)" value="6"></el-option>
<el-option key="7" lable="元素文本不等于期望(NotText)" value="7"></el-option>
<el-option key="8" lable="元素文本等于期望(Text)" value="8"></el-option>
<el-option key="9" lable="元素值等于期望(Value)" value="9"></el-option>
<el-option key="10" lable="元素文本包含期望(InText)" value="10"></el-option>
<el-option key="11" lable="元素文本不包含期望(NotInText)" value="11"></el-option>
</el-select>
<el-input v-model=content.expectations placeholder="请输入期望值"></el-input>
</div>
</div>
</div>
<!-- 下拉框 -->
<div v-if="item.assertionQOList.dropdownBoxes.length > 0" class="information">
<div>下拉框</div>
<div v-for="(content, index2) in item.dropdownBoxes.popupTexts">
<div class="time">
<div class="time-left">
<div class="operateObject-wrap">
<el-select v-model="content.operateObject" class="select">
<el-option key="1" label="元素对象" value="1"></el-option>
<el-option key="2" label="元素定位" value="2"></el-option>
</el-select>
<!-- 元素对象 -->
<div v-show="content.operateObject != '2'" class="operateObject-wrap">
<el-select v-model="content.operateGroupId" class="select" @change="getOperateGroup">
<el-option v-for="item in groupList" :key="item.id" :label="item.name"
:value="item.id"></el-option>
</el-select>
<el-select v-model="content.operateElementId" class="select">
<el-option v-for="item in elementList" :key="item.id" :label="item.name"
:value="item.id"></el-option>
</el-select>
</div>
<!-- 元素定位 -->
<div v-show="content.operateObject === '2'" class="operateObject-wrap">
<el-select v-model="content.operateLocType" class="select" @change="getOperateLoc">
<el-option v-for="item in groupList" :key="item.id" :label="item.name"
:value="item.id"></el-option>
</el-select>
<el-select v-model="content.operateLocValue" class="select">
<el-option v-for="item in elementList" :key="item.id" :label="item.name"
:value="item.id"></el-option>
</el-select>
</div>
</div>
</div>
<div class="time-right">
<el-switch v-model="content.isDisabled" active-value="1" inactive-value="0"
@click.native.stop></el-switch>
<el-button type="text" icon="el-icon-delete" style="color: red;"
@click="deleteAssertion('3', index, index2)"></el-button>
</div>
</div>
<div class="time-left">
<el-select v-model="content.assertionMode">
<el-option key="1" lable="所选元素的值等于期望(SelectedValue)" value="1"></el-option>
<el-option key="2" lable="下拉框选项显示的文本等于期望(SelectedLabel) " value="2"></el-option>
<el-option key="3" lable="所选元素的值不等于期望(NotSelectedValue) " value="3"></el-option>
</el-select>
<el-input v-model=content.expectations placeholder="请输入期望值"></el-input>
</div>
</div>
</div>
<!-- 网页标题 -->
<div v-if="item.assertionQOList.webTitles.length > 0" class="information">
<div>网页标题</div>
<div v-for="(content, index2) in item.webTitles.popupTexts" class="information">
<div class="time-left">
<el-input v-model="content.expectations" placeholder="请输入期望的网页标题"></el-input>
</div>
<div class="time-right">
<el-switch v-model="content.isDisabled" active-value="1" inactive-value="0"
@click.native.stop></el-switch>
<el-button type="text" icon="el-icon-delete" style="color: red;"
@click="deleteAssertion('4', index, index2)"></el-button>
</div>
</div>
</div>
</div>
</el-collapse-item>
</el-collapse>
</div>
</div>
</div>
</el-tab-pane>
@@ -436,6 +613,7 @@ export default {
informationType: '1',
windowType: null,
elementType: null,
assertionType: null,
},
searchForm: {
pageNum: 1,
@@ -549,6 +727,7 @@ export default {
},
// 添加 - 后置操作
addAfter() {
console.log(this.saveForm.after)
if (this.saveForm.after === '1') {
// 等待时间
var param = {
@@ -558,7 +737,7 @@ export default {
isDisabled: '1',
}
this.saveForm.afterList.push(param)
} else {
} else if (this.saveForm.after === '3') {
// 数据提取
var param = {
settingType: '2', // 后置操作
@@ -571,6 +750,21 @@ export default {
name: '数据提取',
}
this.saveForm.afterList.push(param)
} else {
// 断言
var param = {
settingType: '2', // 后置操作
operateType: '2', // 断言
isDisabled: '1',
name: '断言',
assertionQOList: {
popupTexts: [], // 弹窗文本
elementAssertions: [], // 元素断言
dropdownBoxes: [], // 下拉框
webTitles: [], // 网页标题
},
}
this.saveForm.afterList.push(param)
}
},
// 删除
@@ -652,6 +846,62 @@ export default {
afterElemetDelete(val, val1) {
this.saveForm.afterList[val].dataExtractionQOList.elementExtractions = this.saveForm.afterList[val].dataExtractionQOList.elementExtractions.filter((item, index) => index !== val1)
},
// 断言
addAfterAssionQOList(index) {
var param = {
assertionType: this.saveForm.assertionType,
operateObject: null, // 操作对象
operateGroupId: null, // 元素对象
operateElementId: null, // 元素对象
operateLocType: null, // 元素定位
operateLocValue: null, // 元素定位
isDisabled: '1',
expectations: null, // 网页标题
expectations: null, // 期望值
assertionMode: null, // 断言方式
isPopText: null,
}
switch (this.saveForm.assertionType) {
case '1':
// 弹窗文本
this.saveForm.afterList[index].assertionQOList.popupTexts.push(param)
break
case '2':
// 元素断言
this.saveForm.afterList[index].assertionQOList.elementAssertions.push(param)
break
case '3':
// 下拉框
this.saveForm.afterList[index].assertionQOList.dropdownBoxes.push(param)
break
case '4':
// 网页标题
this.saveForm.afterList[index].assertionQOList.webTitles.push(param)
break
}
},
// 断言-删除
deleteAssertion(type, val, val2) {
switch (type) {
case '1':
// 弹窗文本
this.saveForm.afterList[val].assertionQOList.popupTexts = this.saveForm.afterList[val].assertionQOList.popupTexts.filter((item, index) => index !== val2)
break
case '2':
// 元素断言
this.saveForm.afterList[val].assertionQOList.popupTexts = this.saveForm.afterList[val].assertionQOList.elementAssertions.filter((item, index) => index !== val2)
break
case '3':
// 下拉框
this.saveForm.afterList[val].assertionQOList.popupTexts = this.saveForm.afterList[val].assertionQOList.dropdownBoxes.filter((item, index) => index !== val2)
break
case '4':
// 网页标题
this.saveForm.afterList[val].assertionQOList.popupTexts = this.saveForm.afterList[val].assertionQOList.webTitles.filter((item, index) => index !== val2)
break
}
},
// 元素对象
getOperateGroup() {
this.getElementListData(this.saveForm.operateGroupId)
@@ -809,12 +1059,6 @@ export default {
justify-content: space-between;
width: 100%;
.time-left {
display: flex;
align-items: center;
gap: 10px;
}
.time-right {
gap: 10px;
display: flex;
@@ -823,12 +1067,14 @@ export default {
}
}
.time-left {
display: flex;
align-items: center;
gap: 10px;
}
.collapse-content {
padding: 15px;
.information {
padding: 10px;
}
}
}
@@ -837,5 +1083,9 @@ export default {
display: flex;
gap: 10px;
}
.information {
padding: 10px;
}
}
</style>