Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
9a5068b7
U
uni-app
项目概览
DCloud
/
uni-app
6 个月 前同步成功
通知
751
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
9a5068b7
编写于
6月 06, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore(automator): program.tap
上级
d42e853d
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
4 addition
and
4 deletion
+4
-4
packages/uni-app-plus/lib/uni.automator.js
packages/uni-app-plus/lib/uni.automator.js
+1
-1
packages/uni-automator/dist/index.js
packages/uni-automator/dist/index.js
+2
-2
packages/uni-h5/lib/uni.automator.js
packages/uni-h5/lib/uni.automator.js
+1
-1
未找到文件。
packages/uni-app-plus/lib/uni.automator.js
浏览文件 @
9a5068b7
此差异已折叠。
点击以展开。
packages/uni-automator/dist/index.js
浏览文件 @
9a5068b7
此差异已折叠。
点击以展开。
packages/uni-h5/lib/uni.automator.js
浏览文件 @
9a5068b7
"
use strict
"
;
var
e
=
require
(
"
debug
"
),
t
=
require
(
"
postcss-selector-parser
"
),
o
=
require
(
"
fs
"
);
function
r
(
e
){
return
e
&&
"
object
"
==
typeof
e
&&
"
default
"
in
e
?
e
:{
default
:
e
}}
var
n
=
r
(
e
),
a
=
r
(
t
),
s
=
r
(
o
);
const
i
=
n
.
default
(
"
automator:devtool
"
);
function
c
(
e
){
e
.
walk
((
e
=>
{
if
(
"
tag
"
===
e
.
type
){
const
t
=
e
.
value
;
e
.
value
=
"
page
"
===
t
?
"
uni-page-body
"
:
"
uni-
"
+
t
}}))}
const
l
=
[
"
Page.getElement
"
,
"
Page.getElements
"
,
"
Element.getElement
"
,
"
Element.getElements
"
];
function
p
(
e
){
try
{
return
require
(
e
)}
catch
(
t
){
return
require
(
require
.
resolve
(
e
,{
paths
:[
process
.
cwd
()]}))}}
/^win/
.
test
(
process
.
platform
);
const
u
=
[
"
chromium
"
,
"
firefox
"
,
"
webkit
"
];
let
f
=!
1
;
try
{
f
=!!
p
(
"
playwright
"
)}
catch
(
e
){}
const
w
=
new
Map
;
function
h
(
e
=
"
chromium
"
){
const
t
=
e
&&
u
.
includes
(
e
)?
e
:
u
[
0
];
let
o
=
w
.
get
(
t
);
return
o
||
(
o
=
function
(
e
){
if
(
"
webkit
"
===
e
)
return
d
(
"
webkit
"
);
if
(
"
firefox
"
===
e
)
return
d
(
"
firefox
"
);
if
(
f
)
return
d
(
"
chromium
"
);
throw
new
Error
(
"
Playwright dependency not found, please install playwright!
"
)}(
t
),
w
.
set
(
t
,
o
)),
o
}
function
d
(
e
){
const
t
=
p
(
"
playwright
"
);
let
o
,
r
;
return
{
type
:
e
,
provider
:
"
playwright
"
,
async
open
(
n
,
a
,
s
){
o
=
await
t
[
e
].
launch
(
a
.
options
),
"
firefox
"
===
e
&&
(
a
.
contextOptions
.
isMobile
=!
1
),
i
(
`browser.newContext
${
JSON
.
stringify
(
a
.
contextOptions
)}
`
);
const
c
=
await
o
.
newContext
(
a
.
contextOptions
);
r
=
await
c
.
newPage
(),
r
.
on
(
"
console
"
,(
e
=>
{
s
.
emit
(
"
App.logAdded
"
,{
type
:
e
.
type
(),
args
:[
e
.
text
()]})})),
r
.
on
(
"
pageerror
"
,(
e
=>
{
s
.
emit
(
"
App.exceptionThrown
"
,
e
)})),
await
r
.
goto
(
a
.
url
||
n
),
await
r
.
waitForTimeout
(
1
e3
)},
close
:()
=>
o
.
close
(),
screenshot
:(
e
=!
1
)
=>
r
.
screenshot
({
fullPage
:
e
}).
then
((
e
=>
e
.
toString
(
"
base64
"
))),
swipe
:
e
=>
new
Promise
((
async
t
=>
{
const
{
startPoint
:
o
,
endPoint
:
n
}
=
e
;
await
r
.
evaluate
((([
e
,
t
])
=>
{
window
.
scrollBy
({
left
:
e
.
x
-
t
.
x
,
top
:
e
.
y
-
t
.
y
,
behavior
:
"
smooth
"
})}),[
o
,
n
]),
t
(
"
swipe success
"
)}))}}
let
g
;
const
y
=
{
"
Tool.close
"
:{
reflect
:
async
()
=>
{
await
g
.
close
()}},
"
App.exit
"
:{
reflect
:
async
()
=>
{}},
"
App.enableLog
"
:{
reflect
:()
=>
Promise
.
resolve
()},
"
App.captureScreenshot
"
:{
reflect
:
async
(
e
,
t
)
=>
{
const
o
=
await
g
.
screenshot
(
!!
t
.
fullPage
);
return
i
(
`App.captureScreenshot
${
o
.
length
}
`
),{
data
:
o
}}},
"
App.swipe
"
:{
reflect
:
async
(
e
,
t
)
=>
{
const
o
=
await
g
.
swipe
(
t
);
return
i
(
`App.swipe
${
o
.
length
}
`
),{
data
:
o
}}}};
!
function
(
e
){
l
.
forEach
((
t
=>
{
e
[
t
]
=
function
(
e
){
return
{
reflect
:
async
(
t
,
o
)
=>
t
(
e
,
o
,
!
1
),
params
:
e
=>
(
e
.
selector
&&
(
e
.
selector
=
a
.
default
(
c
).
processSync
(
e
.
selector
)),
e
)}}(
t
)}))}(
y
);
const
m
=
{
devtools
:{
name
:
"
browser
"
,
paths
:[],
validate
:
async
function
(
e
){
return
e
.
options
=
e
.
options
||
{},
e
.
executablePath
&&!
e
.
options
.
executablePath
&&
(
e
.
options
.
executablePath
=
e
.
executablePath
),
e
.
contextOptions
=
{
viewport
:
Object
.
assign
({
width
:
375
,
height
:
667
},
e
.
options
.
defaultViewport
||
{}),
hasTouch
:
!
0
,
isMobile
:
!
0
,
deviceScaleFactor
:
2
},
e
.
options
.
defaultViewport
=
Object
.
assign
({
width
:
375
,
height
:
667
,
deviceScaleFactor
:
2
,
hasTouch
:
!
0
,
isMobile
:
!
0
},
e
.
options
.
defaultViewport
||
{}),
e
.
teardown
||
(
e
.
teardown
=!
1
===
e
.
options
.
headless
?
"
disconnect
"
:
"
close
"
),
e
},
create
:
async
function
(
e
,
t
,
o
){
t
.
executablePath
?
await
new
Promise
(((
o
,
r
)
=>
{
const
{
exec
:
n
}
=
require
(
"
node:child_process
"
);
if
(
/^win/
.
test
(
process
.
platform
)){
const
r
=
"
C:
\\
Users
\\
Public
\\
AppData
\\
Local
\\
chrome
"
;
s
.
default
.
existsSync
(
r
)
||
s
.
default
.
mkdirSync
(
r
,{
recursive
:
!
0
}),
n
(
`start
${
t
.
executablePath
}
--user-data-dir=
${
r
}
${
e
}
`
,(
e
=>
{
if
(
e
)
throw
console
.
error
(
`open
${
t
.
executablePath
}
fail,
${
e
}
`
),
Error
(
e
)})),
setTimeout
((()
=>
{
o
(
null
)}),
1
e3
)}
else
n
(
`open -a "
${
t
.
executablePath
}
"
${
e
}
`
,(
e
=>
{
e
&&
(
console
.
error
(
`open
${
t
.
executablePath
}
fail,
${
e
}
`
),
r
(
e
)),
o
(
null
)}))})):(
g
=
h
(
process
.
env
.
BROWSER
),
i
(
"
createDevtools
"
+
(
g
.
provider
+
"
"
+
g
.
type
+
"
"
+
JSON
.
stringify
(
t
))),
await
g
.
open
(
e
,
t
,
o
))}},
shouldCompile
:(
e
,
t
)
=>!
t
.
url
,
adapter
:
y
};
module
.
exports
=
m
;
"
use strict
"
;
var
e
=
require
(
"
debug
"
),
t
=
require
(
"
postcss-selector-parser
"
),
o
=
require
(
"
fs
"
);
function
a
(
e
){
return
e
&&
"
object
"
==
typeof
e
&&
"
default
"
in
e
?
e
:{
default
:
e
}}
var
r
=
a
(
e
),
n
=
a
(
t
),
s
=
a
(
o
);
const
i
=
r
.
default
(
"
automator:devtool
"
);
function
c
(
e
){
e
.
walk
((
e
=>
{
if
(
"
tag
"
===
e
.
type
){
const
t
=
e
.
value
;
e
.
value
=
"
page
"
===
t
?
"
uni-page-body
"
:
"
uni-
"
+
t
}}))}
const
l
=
[
"
Page.getElement
"
,
"
Page.getElements
"
,
"
Element.getElement
"
,
"
Element.getElements
"
];
function
p
(
e
){
try
{
return
require
(
e
)}
catch
(
t
){
return
require
(
require
.
resolve
(
e
,{
paths
:[
process
.
cwd
()]}))}}
/^win/
.
test
(
process
.
platform
);
const
u
=
[
"
chromium
"
,
"
firefox
"
,
"
webkit
"
];
let
w
=!
1
;
try
{
w
=!!
p
(
"
playwright
"
)}
catch
(
e
){}
const
f
=
new
Map
;
function
h
(
e
=
"
chromium
"
){
const
t
=
e
&&
u
.
includes
(
e
)?
e
:
u
[
0
];
let
o
=
f
.
get
(
t
);
return
o
||
(
o
=
function
(
e
){
if
(
"
webkit
"
===
e
)
return
d
(
"
webkit
"
);
if
(
"
firefox
"
===
e
)
return
d
(
"
firefox
"
);
if
(
w
)
return
d
(
"
chromium
"
);
throw
new
Error
(
"
Playwright dependency not found, please install playwright!
"
)}(
t
),
f
.
set
(
t
,
o
)),
o
}
function
d
(
e
){
const
t
=
p
(
"
playwright
"
);
let
o
,
a
;
return
{
type
:
e
,
provider
:
"
playwright
"
,
async
open
(
r
,
n
,
s
){
o
=
await
t
[
e
].
launch
(
n
.
options
),
"
firefox
"
===
e
&&
(
n
.
contextOptions
.
isMobile
=!
1
),
i
(
`browser.newContext
${
JSON
.
stringify
(
n
.
contextOptions
)}
`
);
const
c
=
await
o
.
newContext
(
n
.
contextOptions
);
a
=
await
c
.
newPage
(),
a
.
on
(
"
console
"
,(
e
=>
{
s
.
emit
(
"
App.logAdded
"
,{
type
:
e
.
type
(),
args
:[
e
.
text
()]})})),
a
.
on
(
"
pageerror
"
,(
e
=>
{
s
.
emit
(
"
App.exceptionThrown
"
,
e
)})),
await
a
.
goto
(
n
.
url
||
r
),
await
a
.
waitForTimeout
(
1
e3
)},
close
:()
=>
o
.
close
(),
screenshot
:(
e
=!
1
)
=>
a
.
screenshot
({
fullPage
:
e
}).
then
((
e
=>
e
.
toString
(
"
base64
"
))),
swipe
:
e
=>
new
Promise
((
async
t
=>
{
const
{
startPoint
:
o
,
endPoint
:
r
}
=
e
;
await
a
.
evaluate
((([
e
,
t
])
=>
{
window
.
scrollBy
({
left
:
e
.
x
-
t
.
x
,
top
:
e
.
y
-
t
.
y
,
behavior
:
"
smooth
"
})}),[
o
,
r
]),
t
(
"
swipe success
"
)})),
tap
:
e
=>
new
Promise
((
async
t
=>
{
const
{
x
:
o
,
y
:
r
,
duration
:
n
}
=
e
;
await
a
.
mouse
.
move
(
o
,
r
),
await
a
.
mouse
.
down
(),
await
a
.
waitForTimeout
(
n
||
0
),
await
a
.
mouse
.
up
(),
t
(
"
tap success
"
)}))}}
let
m
;
const
y
=
{
"
Tool.close
"
:{
reflect
:
async
()
=>
{
await
m
.
close
()}},
"
App.exit
"
:{
reflect
:
async
()
=>
{}},
"
App.enableLog
"
:{
reflect
:()
=>
Promise
.
resolve
()},
"
App.captureScreenshot
"
:{
reflect
:
async
(
e
,
t
)
=>
{
const
o
=
await
m
.
screenshot
(
!!
t
.
fullPage
);
return
i
(
`App.captureScreenshot
${
o
.
length
}
`
),{
data
:
o
}}},
"
App.swipe
"
:{
reflect
:
async
(
e
,
t
)
=>
{
const
o
=
await
m
.
swipe
(
t
);
return
i
(
`App.swipe
${
o
.
length
}
`
),{
data
:
o
}}},
"
App.tap
"
:{
reflect
:
async
(
e
,
t
)
=>
{
const
o
=
await
m
.
tap
(
t
);
return
i
(
`App.tap
${
o
.
length
}
`
),{
data
:
o
}}}};
!
function
(
e
){
l
.
forEach
((
t
=>
{
e
[
t
]
=
function
(
e
){
return
{
reflect
:
async
(
t
,
o
)
=>
t
(
e
,
o
,
!
1
),
params
:
e
=>
(
e
.
selector
&&
(
e
.
selector
=
n
.
default
(
c
).
processSync
(
e
.
selector
)),
e
)}}(
t
)}))}(
y
);
const
g
=
{
devtools
:{
name
:
"
browser
"
,
paths
:[],
validate
:
async
function
(
e
){
return
e
.
options
=
e
.
options
||
{},
e
.
executablePath
&&!
e
.
options
.
executablePath
&&
(
e
.
options
.
executablePath
=
e
.
executablePath
),
e
.
contextOptions
=
{
viewport
:
Object
.
assign
({
width
:
375
,
height
:
667
},
e
.
options
.
defaultViewport
||
{}),
hasTouch
:
!
0
,
isMobile
:
!
0
,
deviceScaleFactor
:
2
},
e
.
options
.
defaultViewport
=
Object
.
assign
({
width
:
375
,
height
:
667
,
deviceScaleFactor
:
2
,
hasTouch
:
!
0
,
isMobile
:
!
0
},
e
.
options
.
defaultViewport
||
{}),
e
.
teardown
||
(
e
.
teardown
=!
1
===
e
.
options
.
headless
?
"
disconnect
"
:
"
close
"
),
e
},
create
:
async
function
(
e
,
t
,
o
){
t
.
executablePath
?
await
new
Promise
(((
o
,
a
)
=>
{
const
{
exec
:
r
}
=
require
(
"
node:child_process
"
);
if
(
/^win/
.
test
(
process
.
platform
)){
const
a
=
"
C:
\\
Users
\\
Public
\\
AppData
\\
Local
\\
chrome
"
;
s
.
default
.
existsSync
(
a
)
||
s
.
default
.
mkdirSync
(
a
,{
recursive
:
!
0
}),
r
(
`start
${
t
.
executablePath
}
--user-data-dir=
${
a
}
${
e
}
`
,(
e
=>
{
if
(
e
)
throw
console
.
error
(
`open
${
t
.
executablePath
}
fail,
${
e
}
`
),
Error
(
e
)})),
setTimeout
((()
=>
{
o
(
null
)}),
1
e3
)}
else
r
(
`open -a "
${
t
.
executablePath
}
"
${
e
}
`
,(
e
=>
{
e
&&
(
console
.
error
(
`open
${
t
.
executablePath
}
fail,
${
e
}
`
),
a
(
e
)),
o
(
null
)}))})):(
m
=
h
(
process
.
env
.
BROWSER
),
i
(
"
createDevtools
"
+
(
m
.
provider
+
"
"
+
m
.
type
+
"
"
+
JSON
.
stringify
(
t
))),
await
m
.
open
(
e
,
t
,
o
))}},
shouldCompile
:(
e
,
t
)
=>!
t
.
url
,
adapter
:
y
};
module
.
exports
=
g
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录