Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 在获取元素页面中快捷测试元素定位是否可以定位并点击 #296

Merged
merged 4 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/components/ElementUpdate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ const props = defineProps({
projectId: Number,
elementId: Number,
elementObj: Object,
isRemotePage: Boolean,
checkLoading: Boolean,
});
const emit = defineEmits(['flush']);
const emit = defineEmits(['flush', 'checkLocation']);
const element = ref({
id: null,
eleName: '',
Expand Down Expand Up @@ -76,6 +78,9 @@ const saveElement = () => {
}
});
};
const testElement = () => {
emit('checkLocation', element.value);
};
const moduleList = ref([]);
const getModuleList = () => {
axios
Expand Down Expand Up @@ -216,6 +221,15 @@ onMounted(() => {
</el-select>
</el-form-item>
<div style="text-align: center">
<el-button
v-if="isRemotePage"
size="small"
type="warning"
:loading="checkLoading"
:disabled="checkLoading"
@click="testElement"
>{{ $t('form.test') }}</el-button
>
<el-button size="small" type="primary" @click="saveElement">{{
$t('form.save')
}}</el-button>
Expand Down
1 change: 1 addition & 0 deletions src/locales/lang/en_US.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ const form = {
inputNewPasswordAgain: 'Please input your new password again',
confirm: 'Confirm',
cancel: 'Cancel',
test: 'Test',
};
// 弹窗相关
const dialog = {
Expand Down
1 change: 1 addition & 0 deletions src/locales/lang/ja_JP.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ const form = {
inputNewPasswordAgain: '新パスワードを再度入力してください',
confirm: '確定',
cancel: 'キャンセル',
test: 'テスト',
};
// 弹窗相关
const dialog = {
Expand Down
1 change: 1 addition & 0 deletions src/locales/lang/zh_CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ const form = {
inputNewPasswordAgain: '请再次输入新密码',
confirm: '确定',
cancel: '取消',
test: '测试',
};
// 弹窗相关
const dialog = {
Expand Down
1 change: 1 addition & 0 deletions src/locales/lang/zh_TW.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ const form = {
inputNewPasswordAgain: '請再次輸入新密碼',
confirm: '確定',
cancel: '取消',
test: '測試',
};
// 彈出型視窗相關
const dialog = {
Expand Down
121 changes: 111 additions & 10 deletions src/views/RemoteEmulator/AndroidRemote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import {
Service,
VideoCamera,
Postcard,
Location,
} from '@element-plus/icons';

import { useI18n } from 'vue-i18n';
Expand Down Expand Up @@ -148,6 +149,7 @@ const activeTab = ref('main');
const activeTab2 = ref('step');
const stepLog = ref([]);
const debugLoading = ref(false);
const checkElementLoading = ref(false);
const dialogElement = ref(false);
const dialogImgElement = ref(false);
const imgElementUrl = ref(null);
Expand Down Expand Up @@ -557,30 +559,23 @@ const stopLogcat = () => {
);
};
const saveLogcat = () => {
if (logcatOutPut && Array.isArray(logcatOutPut.value)) {

if (logcatOutPut.value && Array.isArray(logcatOutPut.value)) {
const logContent = logcatOutPut.value.join('\n');

const blob = new Blob([logContent], { type: 'text/plain;charset=utf-8' });

const url = URL.createObjectURL(blob);

const now = new Date();
const formattedDate = now.toISOString().replace(/:/g, '-').split('.')[0];
const modelName = device.value['model'];
const modelName = device.value.model;
const fileName = `${modelName}_${formattedDate}.log`;

const a = document.createElement('a');
a.href = url;

a.download = fileName;
document.body.appendChild(a);
a.click();

document.body.removeChild(a);
URL.revokeObjectURL(url);
} else {
console.error("logcatOutPut or logcatOutPut.value not expect");
console.error('logcatOutPut or logcatOutPut.value not expect');
}
};

Expand Down Expand Up @@ -867,6 +862,7 @@ const websocketOnmessage = (message) => {
}
case 'status': {
debugLoading.value = false;
checkElementLoading.value = false;
ElMessage.info({
message: $t('androidRemoteTS.runOver'),
});
Expand Down Expand Up @@ -1370,6 +1366,18 @@ const runStep = () => {
})
);
};
const checkLocation = (data) => {
checkElementLoading.value = true;
websocket.send(
JSON.stringify({
type: 'debug',
detail: 'checkLocation',
element: data.eleValue,
eleType: data.eleType,
pwd: device.value.password,
})
);
};
const stopStep = () => {
debugLoading.value = false;
websocket.send(
Expand Down Expand Up @@ -1825,7 +1833,10 @@ const checkAlive = () => {
:project-id="project['id']"
:element-id="0"
:element-obj="element"
:is-remote-page="true"
:check-loading="checkElementLoading"
@flush="dialogElement = false"
@check-location="checkLocation"
/>
</el-dialog>
<remote-page-header
Expand Down Expand Up @@ -3699,6 +3710,23 @@ const checkAlive = () => {
@click="copy(elementDetail['resource-id'])"
>{{ elementDetail['resource-id'] }}</span
>
<el-icon
color="green"
size="16"
style="
vertical-align: middle;
margin-left: 10px;
cursor: pointer;
"
@click="
checkLocation({
eleType: 'id',
eleValue: elementDetail['resource-id'],
})
"
>
<Location />
</el-icon>
<el-icon
v-if="project && project['id']"
color="green"
Expand Down Expand Up @@ -3737,6 +3765,23 @@ const checkAlive = () => {
@click="copy(scope.row)"
>{{ scope.row }}</span
>
<el-icon
color="green"
size="16"
style="
vertical-align: middle;
margin-left: 10px;
cursor: pointer;
"
@click="
checkLocation({
eleType: 'xpath',
eleValue: scope.row,
})
"
>
<Location />
</el-icon>
<el-icon
v-if="project && project['id']"
color="green"
Expand All @@ -3763,6 +3808,23 @@ const checkAlive = () => {
<span @click="copy(elementDetail['xpath'])">{{
elementDetail['xpath']
}}</span>
<el-icon
color="green"
size="16"
style="
vertical-align: middle;
margin-left: 10px;
cursor: pointer;
"
@click="
checkLocation({
eleType: 'xpath',
eleValue: elementDetail['xpath'],
})
"
>
<Location />
</el-icon>
<el-icon
v-if="project && project['id']"
color="green"
Expand Down Expand Up @@ -3798,6 +3860,23 @@ const checkAlive = () => {
@click="copy(elementDetail['content-desc'])"
>{{ elementDetail['content-desc'] }}</span
>
<el-icon
color="green"
size="16"
style="
vertical-align: middle;
margin-left: 10px;
cursor: pointer;
"
@click="
checkLocation({
eleType: 'accessibilityId',
eleValue: elementDetail['content-desc'],
})
"
>
<Location />
</el-icon>
<el-icon
v-if="project && project['id']"
color="green"
Expand Down Expand Up @@ -3844,6 +3923,28 @@ const checkAlive = () => {
)
}}</span
>
<el-icon
color="green"
size="16"
style="
vertical-align: middle;
margin-left: 10px;
cursor: pointer;
"
@click="
checkLocation({
eleType: 'point',
eleValue: computedCenter(
elementDetail['x'],
elementDetail['y'],
elementDetail['width'],
elementDetail['height']
),
})
"
>
<Location />
</el-icon>
<el-icon
v-if="project && project['id']"
color="green"
Expand Down
Loading
Loading