Commit 20fadfd2 authored by Wallen姚文辉's avatar Wallen姚文辉

Merge branch 'mailmade' into 'master'

增加安卓自动化测试工具

See merge request !3
parents c4c8f8a3 0c35b04f
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="stylesheet" href="/dist/plugins/css/pluginsCss.css"/><link rel="stylesheet" href="/dist/plugins/plugins.css"/><link rel="stylesheet" href="/dist/css/luckysheet.css"/><link rel="stylesheet" href="/dist/assets/iconfont/iconfont.css"/><script src="/dist/plugins/js/plugin.js"></script><script src="/dist/luckysheet.umd.js"></script><title>yinhe_test</title><script defer="defer" src="/js/chunk-vendors.c8e13258.js"></script><script defer="defer" src="/js/app.f2362e6e.js"></script><link href="/css/chunk-vendors.187ae3e6.css" rel="stylesheet"><link href="/css/app.df7fa4e2.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but yinhe_test doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html> <!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="stylesheet" href="/dist/plugins/css/pluginsCss.css"/><link rel="stylesheet" href="/dist/plugins/plugins.css"/><link rel="stylesheet" href="/dist/css/luckysheet.css"/><link rel="stylesheet" href="/dist/assets/iconfont/iconfont.css"/><script src="/dist/plugins/js/plugin.js"></script><script src="/dist/luckysheet.umd.js"></script><title>yinhe_test</title><script defer="defer" src="/js/chunk-vendors.9926850b.js"></script><script defer="defer" src="/js/app.698ebd0f.js"></script><link href="/css/chunk-vendors.187ae3e6.css" rel="stylesheet"><link href="/css/app.df7fa4e2.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but yinhe_test doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
\ No newline at end of file \ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
"@vue-flow/controls": "^1.1.2", "@vue-flow/controls": "^1.1.2",
"@vue-flow/core": "^1.41.1", "@vue-flow/core": "^1.41.1",
"@vue-flow/node-resizer": "^1.4.0", "@vue-flow/node-resizer": "^1.4.0",
"ansi_up": "^6.0.2",
"balm-ui": "^10.28.0", "balm-ui": "^10.28.0",
"clipboard": "^2.0.11", "clipboard": "^2.0.11",
"core-js": "^3.8.3", "core-js": "^3.8.3",
...@@ -4403,6 +4404,14 @@ ...@@ -4403,6 +4404,14 @@
"ajv": "^6.9.1" "ajv": "^6.9.1"
} }
}, },
"node_modules/ansi_up": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/ansi_up/-/ansi_up-6.0.2.tgz",
"integrity": "sha512-3G3vKvl1ilEp7J1u6BmULpMA0xVoW/f4Ekqhl8RTrJrhEBkonKn5k3bUc5Xt+qDayA6iDX0jyUh3AbZjB/l0tw==",
"engines": {
"node": "*"
}
},
"node_modules/ansi-colors": { "node_modules/ansi-colors": {
"version": "4.1.3", "version": "4.1.3",
"resolved": "https://registry.npmmirror.com/ansi-colors/-/ansi-colors-4.1.3.tgz", "resolved": "https://registry.npmmirror.com/ansi-colors/-/ansi-colors-4.1.3.tgz",
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<span style="color: #17233d;margin-right: 10px;">远端状态:</span> <span style="color: #17233d;margin-right: 10px;">远端状态:</span>
<div v-if="connectSatus" style="display: inline;"> <div v-if="connectSatus" style="display: inline;">
<span style="margin-right: 10px;color: #19be6b;">连接中</span> <span style="margin-right: 10px;color: #19be6b;">连接中</span>
<Button type="info" @click="killssh">断开连接</Button> <Button size="small" type="info" @click="killssh">断开连接</Button>
</div> </div>
<div v-else style="display: inline;"> <div v-else style="display: inline;">
<Icon type="md-warning" color="#ed4014" size="25" /><span style="color: #ed4014;">未连接</span> <Icon type="md-warning" color="#ed4014" size="25" /><span style="color: #ed4014;">未连接</span>
...@@ -34,11 +34,11 @@ ...@@ -34,11 +34,11 @@
<div> <div>
<span style="color: #17233d;margin-right: 10px;">连接命令:</span> <span style="color: #17233d;margin-right: 10px;">连接命令:</span>
<span style="margin-right: 10px;">ssh -N -R 3240:localhost:3240 root@192.168.11.185</span> <span style="margin-right: 10px;">ssh -N -R 3240:localhost:3240 root@192.168.11.185</span>
<Button style="margin-right: 10px;" type="info" @click="copyConnectCmd">复制</Button> <Button size="small" style="margin-right: 10px;" type="info" @click="copyinfo('connect')">复制</Button>
</div> </div>
<div style="text-align: center;"> <div style="text-align: center;">
<Button style="margin-top: 5px;margin-right: 10px;" type="info" <Button size="small" style="margin-top: 5px;margin-right: 10px;" type="info"
@click="copyConnectPass">复制连接密码</Button> @click="copyinfo('connectPass')">复制连接密码</Button>
</div> </div>
</div> </div>
<div style="text-align: center;margin-top: 5px;"> <div style="text-align: center;margin-top: 5px;">
...@@ -46,19 +46,29 @@ ...@@ -46,19 +46,29 @@
<span style="color: #17233d;margin-right: 10px;">appium:</span> <span style="color: #17233d;margin-right: 10px;">appium:</span>
<div v-if="appiumStatus" style="display: inline;"> <div v-if="appiumStatus" style="display: inline;">
<span style="margin-right: 10px;color: #19be6b;">已启动</span> <span style="margin-right: 10px;color: #19be6b;">已启动</span>
<Button style="margin-right: 10px;" type="info" @click="restartAppium" <Button size="small" style="margin-right: 10px;" type="info" @click="restartAppium"
:disabled="canRestartAppium">重启</Button> :disabled="canRestartAppium">重启</Button>
<Button type="info" @click="">查看日志</Button> <Button size="small" type="info" @click="tailLog">查看日志</Button>
</div> </div>
<div v-else style="display: inline;"> <div v-else style="display: inline;">
<span style="margin-right: 10px;color: #19be6b;">未启动</span> <span style="margin-right: 10px;color: #19be6b;">未启动</span>
<Button type="info" @click="startAppium" :disabled="canRestartAppium">启动</Button> <Button size="small" type="info" @click="startAppium" :disabled="canRestartAppium">启动</Button>
</div>
<div v-if="appiumStatus" style="margin-top: 5px;">
<span style="color: #17233d;margin-right: 10px;">appium远程主机:</span>
<span style="margin-right: 10px;">192.168.11.185</span>
<Button size="small" style="margin-right: 10px;" type="info" @click="copyinfo('appiumHost')">复制</Button>
</div>
<div v-if="appiumStatus" style="margin-top: 5px;">
<span style="color: #17233d;margin-right: 10px;">appium远程端口:</span>
<span style="margin-right: 10px;">4567</span>
<Button size="small" style="margin-right: 10px;" type="info" @click="copyinfo('appiumPort')">复制</Button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
</PageHeader> </PageHeader>
<div v-if="usbInfo.arr.filter(item => item.status == 1).length"> <div v-if="usbInfo.arr.filter(item => item.status == 1).length">
<Row style="margin-top: 20px;"> <Row style="margin-top: 20px;">
...@@ -89,6 +99,13 @@ ...@@ -89,6 +99,13 @@
@click="copyappiumconn">复制参数</Button> @click="copyappiumconn">复制参数</Button>
<Button v-if="selectSystem == 1" style="margin-top: 10px;" @click="disconnectAndroid">断开连接</Button> <Button v-if="selectSystem == 1" style="margin-top: 10px;" @click="disconnectAndroid">断开连接</Button>
</div> </div>
<div>
<Button style="margin-right: 5px;margin-top: 10px;"
v-if="Object.getOwnPropertyNames(androidConnectInfo.appiumArgs).length"
@click="setAppuimInfo">修改参数</Button>
<Button v-if="Object.getOwnPropertyNames(androidConnectInfo.appiumArgs).length"
style="margin-top: 10px;" @click="disconnectAndroid" disabled>运行脚本</Button>
</div>
</div> </div>
</Col> </Col>
...@@ -96,7 +113,8 @@ ...@@ -96,7 +113,8 @@
<div v-if="selectSystem == 0 || selectSystem == 2" class="phone" style="border-color: #c5c8ce;"> <div v-if="selectSystem == 0 || selectSystem == 2" class="phone" style="border-color: #c5c8ce;">
<Icon style="margin-top: 50px;" type="logo-apple" size="100" color="#808695" /> <Icon style="margin-top: 50px;" type="logo-apple" size="100" color="#808695" />
<Input v-model="webdriveragentId" placeholder="请输入webdriveragentId" style="width: 200px;" /> <Input v-model="webdriveragentId" placeholder="请输入webdriveragentId" style="width: 200px;" />
<Button v-if="selectSystem == 0" style="margin-top: 10px;" @click="connectIos">连接</Button> <Button v-if="selectSystem == 0" style="margin-top: 10px;" @click="connectIos" disabled>连接</Button>
<p style="color: #ed4014;">最新版的ios连接不稳定,尚在调试和寻找处理方法</p>
<p> <p>
<Icon v-if="selectSystem == 2 && !iosConnectInfo?.IosId" type="ios-loading" class="ivu-anim-loop" <Icon v-if="selectSystem == 2 && !iosConnectInfo?.IosId" type="ios-loading" class="ivu-anim-loop"
size="24" /> size="24" />
...@@ -118,24 +136,62 @@ ...@@ -118,24 +136,62 @@
</Col> </Col>
</Row> </Row>
</div> </div>
<Drawer title="appium日志" :closable="false" height="80" v-model="LogDrawer" placement="bottom">
<div ref="logBox" style="height: 92%; overflow:scroll; background-color: black;font-size: 18px">
</div>
</Drawer>
<Modal v-model="appiumModal" :title="ModalTitle()" @on-ok="save" @on-cancel="cancel">
<div style="margin-top: 5px;" v-for="item, index in LinShiAppuim.info">
<Input v-model="item.key" style="width: 200px;margin-right: 5px;" />
<span style="display: inline;margin-right: 5px;">:</span>
<Input v-model="item.value" style="width: 200px;margin-right: 5px" />
<Button style="display: inline;" size="small" icon="md-remove" type="error" shape="circle"
@click="removeLishItem(index)"></Button>
</div>
<Button style="margin-top: 15px;" size="small" icon="md-add" type="primary" shape="circle"
@click="addLishiItem()"></Button>
</Modal>
</template> </template>
<script setup> <script setup>
import { ref, reactive, onMounted, getCurrentInstance, watch, onUnmounted } from 'vue' import { ref, reactive, onMounted, getCurrentInstance, watch, onUnmounted, nextTick } from 'vue'
// import clipboard from 'clipboard'; // import clipboard from 'clipboard';
import useClipboard from 'vue-clipboard3'; import useClipboard from 'vue-clipboard3';
import { AnsiUp } from 'ansi_up'
const ansi_up = new AnsiUp();
ansi_up.escape_html = false
const { proxy, ctx } = getCurrentInstance() const { proxy, ctx } = getCurrentInstance()
let Message = proxy.$Message let Message = proxy.$Message
let socket = proxy.$socket let socket = proxy.$socket
const { toClipboard } = useClipboard(); const { toClipboard } = useClipboard();
let appiumStatus = ref(false)
const appiumModal = ref(false)
let appiumStatus = ref(false)
let canRestartAppium = ref(false) let canRestartAppium = ref(false)
let LogDrawer = ref(false)
let logBox = ref(null)
let LogButtom = ref(false)
let LinShiAppuim = reactive({
info: []
})
const copycmd={
connect:'ssh -N -R 3240:localhost:3240 root@192.168.11.185',
connectPass:'galaxy123',
appiumHost:'192.168.11.185',
appiumPort:'4567'
}
let title = ref('移动端自动化') let title = ref('移动端自动化')
let webdriveragentId = ref(null) let webdriveragentId = ref(null)
...@@ -157,7 +213,8 @@ let selectSystem = ref(0) ...@@ -157,7 +213,8 @@ let selectSystem = ref(0)
let connectSatus = ref(false) let connectSatus = ref(false)
let usbInfo = reactive({ arr: [] }) let usbInfo = reactive({ arr: [] })
let appiumLogs = reactive({ arr: [] }) let nowRender = null
let buttomLine = ''
let androidConnectInfo = reactive({ let androidConnectInfo = reactive({
adbinfo: null, adbinfo: null,
...@@ -222,6 +279,7 @@ watch( ...@@ -222,6 +279,7 @@ watch(
} }
}) })
function getlowV(k, v) { function getlowV(k, v) {
if (k.length + v.length + 2 >= 27) { if (k.length + v.length + 2 >= 27) {
return [true, v.slice(0, 25 - k.length - 1) + '...'] return [true, v.slice(0, 25 - k.length - 1) + '...']
...@@ -240,7 +298,7 @@ function connectAndroid() { ...@@ -240,7 +298,7 @@ function connectAndroid() {
selectSystem.value = 1 selectSystem.value = 1
socket.on("adbFlush", (data) => { socket.on("adbFlush", (data) => {
androidConnectInfo.adbinfo = data androidConnectInfo.adbinfo = data
if (data) { if (data && !Object.keys(androidConnectInfo.appiumArgs).length) {
console.log(data.split(' ')) console.log(data.split(' '))
androidConnectInfo.appiumArgs = { androidConnectInfo.appiumArgs = {
"platformName": "Android", "platformName": "Android",
...@@ -260,12 +318,16 @@ function connectIos() { ...@@ -260,12 +318,16 @@ function connectIos() {
selectSystem.value = 2 selectSystem.value = 2
socket.on('iosinfo', data => { socket.on('iosinfo', data => {
for (var k in data) { for (var k in data) {
iosConnectInfo[k]=data[k] iosConnectInfo[k] = data[k]
} }
}) })
socket.emit('connectIOS', webdriveragentId.value) socket.emit('connectIOS', webdriveragentId.value)
} }
function tailLog() {
LogDrawer.value = true
}
function disconnectAndroid() { function disconnectAndroid() {
selectSystem.value = 0 selectSystem.value = 0
socket.emit('leaveAdbinfo') socket.emit('leaveAdbinfo')
...@@ -276,11 +338,11 @@ function disconnectAndroid() { ...@@ -276,11 +338,11 @@ function disconnectAndroid() {
function disconnectIos() { function disconnectIos() {
selectSystem.value = 0 selectSystem.value = 0
if (iosConnectInfo?.IosId ) { if (iosConnectInfo?.IosId) {
socket.off('iosinfo') socket.off('iosinfo')
socket.emit('disconnectIOS', webdriveragentId.value) socket.emit('disconnectIOS', webdriveragentId.value)
iosConnectInfo = { iosConnectInfo = {
appiumArgs:{} appiumArgs: {}
} }
} }
} }
...@@ -306,17 +368,22 @@ function startAppium() { ...@@ -306,17 +368,22 @@ function startAppium() {
// selectSystem.value = 0 // selectSystem.value = 0
// } // }
async function copyConnectCmd() { async function copyinfo(key) {
const text = "ssh -N -R 3240:localhost:3240 root@192.168.11.185" await toClipboard(copycmd[key])
await toClipboard(text)
Message.success("复制成功") Message.success("复制成功")
} }
async function copyConnectPass() { // async function copyConnectCmd() {
const text = "galaxy123" // const text = "ssh -N -R 3240:localhost:3240 root@192.168.11.185"
await toClipboard(text) // await toClipboard(text)
Message.success("复制成功") // Message.success("复制成功")
} // }
// async function copyConnectPass() {
// const text = "galaxy123"
// await toClipboard(text)
// Message.success("复制成功")
// }
function killssh() { function killssh() {
socket.emit('killproxy') socket.emit('killproxy')
...@@ -327,6 +394,86 @@ function bindusb(key) { ...@@ -327,6 +394,86 @@ function bindusb(key) {
socket.emit('connectUsb', key) socket.emit('connectUsb', key)
} }
function setAppuimInfo() {
if (selectSystem.value != 1 && selectSystem.value != 2) return Message.error('未知的手机系统');
let selet = null
if (selectSystem.value == 1) {
selet = androidConnectInfo.appiumArgs
} else if (selectSystem.value == 2) {
selet = iosConnectInfo.appiumArgs
}
for (let i in selet) {
LinShiAppuim.info.push({ key: i, value: selet[i] })
}
appiumModal.value = true
}
function renderLog(data) {
// console.info(data)
LogButtom.value = (logBox.value.scrollHeight - logBox.value.scrollTop <= logBox.value.clientHeight + 10 || (logBox.value.scrollTop == 0 && logBox.value.clientHeight == logBox.value.scrollHeight)) ? true : false
const result = data.replace('\t', '&emsp;').split('\n')
result[0] = (buttomLine + result[0])
buttomLine = result[result.length - 1]
for (let i = 0; i < result.length; i++) {
if (i == result.length - 1) {
if (!nowRender) {
nowRender = document.createElement("p");
nowRender.innerHTML = ansi_up.ansi_to_html(result[i])
logBox.value.appendChild(nowRender)
} else {
nowRender.innerHTML = ansi_up.ansi_to_html(result[i])
}
buttomLine = result[i]
} else {
const res = document.createElement("p")
res.innerHTML = ansi_up.ansi_to_html(result[i])
logBox.value.appendChild(res)
}
}
if (LogButtom.value) logBox.value.scrollTop = logBox.value.scrollHeight
}
function removeLishItem(k) {
LinShiAppuim.info.splice(k, 1)
}
function addLishiItem() {
LinShiAppuim.info.push({ key: '', value: '' })
}
function save() {
let result = {}
console.info("进来了")
for (var item of LinShiAppuim.info) {
console.info(item)
if (item.key == '' || item.key == null || item.value == '' || item.value == null) {
return Message.error('请完善信息')
} else {
result[item.key] = item.value
}
}
console.info(result)
if (selectSystem.value != 1 && selectSystem.value != 2) return Message.error('未知的手机系统');
if (selectSystem.value == 1)
androidConnectInfo.appiumArgs = result
else if (selectSystem.value == 2)
iosConnectInfo.appiumArgs = result
cancel()
}
function cancel() {
LinShiAppuim.info = []
appiumModal.value = false
}
function ModalTitle() {
if (selectSystem.value == 1) return '安卓appuim连接参数编辑'
if (selectSystem.value == 2) return 'ios appuim连接参数编辑'
}
onMounted(() => { onMounted(() => {
socket.connect() socket.connect()
socket.on('usbFlush', (data) => { socket.on('usbFlush', (data) => {
...@@ -338,14 +485,20 @@ onMounted(() => { ...@@ -338,14 +485,20 @@ onMounted(() => {
socket.on('appiumstatus', (data) => { socket.on('appiumstatus', (data) => {
appiumStatus.value = data appiumStatus.value = data
}) })
socket.on('appiumlog', (data) => {
appiumLogs.arr = data
})
socket.emit("usbInfo") socket.emit("usbInfo")
socket.emit('appiumLog')
socket.on('sendappiumLog', (data) => { renderLog(data) })
}) })
onUnmounted(() => { onUnmounted(() => {
disconnectIos() disconnectIos()
socket.emit('leaveappiumLog')
socket.off('sendappiumLog')
socket.off('usbFlush')
socket.off('sshFlush')
socket.off('appiumstatus')
}) })
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment