Skip to content

Commit

Permalink
Merge pull request #250 from caofengbin/feature/complete_text_assert
Browse files Browse the repository at this point in the history
feat,将原有的“验证文本”改为“断言文本”,允许指定比较方式为等于,不等于,包含,不包含四种模式,满足更丰富的应用场景
  • Loading branch information
ZhouYixun authored May 22, 2023
2 parents 25a414e + 8397259 commit c3fb0ed
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 17 deletions.
33 changes: 33 additions & 0 deletions src/components/StepShow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ const getPublicStepInfo = (id) => {
});
};
const getAssertTextOpe = (s) => {
switch (s) {
case 'equal':
return '等于';
case 'notEqual':
return '不等于';
case 'contain':
return '包含';
case 'notContain':
return '不包含';
default:
return '未知类型';
}
};
const getEleResult = (s) => {
const ss = s.toUpperCase();
if (ss.indexOf('POCO') !== -1) {
Expand Down Expand Up @@ -439,6 +454,7 @@ const getNotes = (text, type) => {
<el-tag size="small">获取剪切板文本</el-tag>
获取到变量:{{ step.content }}
</span>
<!--三个指令前端显示上保留,用于兼容老版本升级上来之后,依然能正常的显示和运行-->
<span
v-if="
step.stepType === 'getText' ||
Expand All @@ -454,6 +470,23 @@ const getNotes = (text, type) => {
>{{ step.elements[0]['eleName'] }}</el-tag
>
期望值:{{ step.content }}
</span>
<!--大于2.5.0版本,增强的文本断言能力-->
<span
v-if="
step.stepType === 'assertText' ||
step.stepType === 'assertWebViewText' ||
step.stepType === 'assertPocoText'
"
>
<el-tag size="small">断言{{ getEleResult(step.stepType) }}文本</el-tag>
<el-tag
type="info"
size="small"
style="margin-left: 10px; margin-right: 10px"
>{{ step.elements[0]['eleName'] }}</el-tag
> 期望:
<el-tag size="small" style="margin-left: 10px; margin-right: 10px">{{ getAssertTextOpe(step.content) }}</el-tag>{{ step.text }}
</span>
<span v-if="step.stepType === 'getTitle'">
<el-tag size="small" style="margin-right: 10px">验证标题</el-tag>
Expand Down
60 changes: 43 additions & 17 deletions src/components/StepUpdate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ const getStepInfo = (id) => {
monkey.value = JSON.parse(step.value.content);
activityList.value = JSON.parse(step.value.text);
}
if (
step.value.stepType === 'assertText' ||
step.value.stepType === 'assertWebViewText' ||
step.value.stepType === 'assertPocoText'
) {
step.value.content = JSON.parse(step.value.content);
step.value.text = JSON.parse(step.value.text);
}
});
};
const publicStepList = ref([]);
Expand Down Expand Up @@ -542,8 +550,8 @@ const androidOptions = ref([
label: '获取文本',
},
{
value: 'getText',
label: '验证文本',
value: 'assertText',
label: '断言文本',
},
{
value: 'logElementAttr',
Expand Down Expand Up @@ -618,8 +626,8 @@ const androidOptions = ref([
label: '获取文本',
},
{
value: 'getWebViewText',
label: '验证文本',
value: 'assertWebViewText',
label: '断言文本',
},
{
value: 'getTitle',
Expand Down Expand Up @@ -696,8 +704,8 @@ const androidOptions = ref([
label: '获取文本',
},
{
value: 'getPocoText',
label: '验证文本',
value: 'assertPocoText',
label: '断言文本',
},
{
value: 'logPocoElementAttr',
Expand Down Expand Up @@ -936,8 +944,8 @@ const iOSOptions = ref([
label: '获取文本',
},
{
value: 'getText',
label: '验证文本',
value: 'assertText',
label: '断言文本',
},
{
value: 'logElementAttr',
Expand Down Expand Up @@ -1024,8 +1032,8 @@ const iOSOptions = ref([
label: '获取文本',
},
{
value: 'getPocoText',
label: '验证文本',
value: 'assertPocoText',
label: '断言文本',
},
{
value: 'logPocoElementAttr',
Expand Down Expand Up @@ -2099,15 +2107,16 @@ onMounted(() => {
</el-form-item>
</div>

<!--这里UI上还需要保留,用于在老版本升级上来之后,可以编辑用-->
<div
v-if="step.stepType === 'getText' || step.stepType === 'getWebViewText'"
v-if="step.stepType === 'getText' || step.stepType === 'getWebViewText' || step.stepType === 'getPocoText'"
>
<element-select
label="控件元素"
place="请选择控件元素"
:index="0"
:project-id="projectId"
type="normal"
:type="step.stepType === 'getPocoText' ? 'poco' : 'normal'"
:step="step"
/>
<el-form-item label="期望值">
Expand All @@ -2118,23 +2127,40 @@ onMounted(() => {
</el-form-item>
</div>

<div v-if="step.stepType === 'getPocoText'">
<!-- >2.5版本之后,增强类型的文本断言 -->
<div
v-if="step.stepType === 'assertText' || step.stepType === 'assertWebViewText' || step.stepType === 'assertPocoText'"
>
<element-select
label="控件元素"
place="请选择控件元素"
:index="0"
:project-id="projectId"
type="poco"
:type="step.stepType === 'assertPocoText' ? 'poco' : 'normal'"
:step="step"
/>
<el-form-item label="期望值">
<el-form-item
label="断言类型"
prop="content"
:rules="{required: true, message: '断言类型不能为空', trigger: 'change'}"
>
<el-select v-model="step.content">
<el-option label="等于" value="equal"></el-option>
<el-option label="不等于" value="notEqual"></el-option>
<el-option label="包含" value="contain"></el-option>
<el-option label="不包含" value="notContain"></el-option>
</el-select>
</el-form-item>
<el-form-item
label="期望值"
prop="text"
:rules="{required: true, message: '期望值不能为空', trigger: 'change'}">
<el-input
v-model="step.content"
v-model="step.text"
placeholder="请输入期望值"
></el-input>
</el-form-item>
</div>

<div v-if="step.stepType === 'getTitle' || step.stepType === 'getUrl'">
<el-form-item label="期望值">
<el-input
Expand Down

0 comments on commit c3fb0ed

Please sign in to comment.