Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
85ac9b04
U
uni-app
项目概览
DCloud
/
uni-app
5 天 前同步成功
通知
815
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看板
提交
85ac9b04
编写于
1月 15, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perf(web): 自动化测试,移除 chrome 启动警告信息
上级
520aac5f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
packages/uni-h5/lib/uni.automator.js
packages/uni-h5/lib/uni.automator.js
+1
-1
未找到文件。
packages/uni-h5/lib/uni.automator.js
浏览文件 @
85ac9b04
"
use strict
"
;
var
e
=
require
(
"
debug
"
),
t
=
require
(
"
postcss-selector-parser
"
);
function
o
(
e
){
return
e
&&
"
object
"
==
typeof
e
&&
"
default
"
in
e
?
e
:{
default
:
e
}}
var
n
=
o
(
e
),
r
=
o
(
t
);
const
a
=
n
.
default
(
"
automator:devtool
"
);
function
s
(
e
){
e
.
walk
((
e
=>
{
if
(
"
tag
"
===
e
.
type
){
const
t
=
e
.
value
;
e
.
value
=
"
page
"
===
t
?
"
uni-page-body
"
:
"
uni-
"
+
t
}}))}
const
c
=
[
"
Page.getElement
"
,
"
Page.getElements
"
,
"
Element.getElement
"
,
"
Element.getElements
"
];
function
i
(
e
){
try
{
return
require
(
e
)}
catch
(
t
){
return
require
(
require
.
resolve
(
e
,{
paths
:[
process
.
cwd
()]}))}}
/^win/
.
test
(
process
.
platform
);
const
l
=
[
"
chromium
"
,
"
firefox
"
,
"
webkit
"
];
let
p
=!
1
;
try
{
p
=!!
i
(
"
playwright
"
)}
catch
(
e
){}
const
u
=
new
Map
;
function
h
(
e
=
"
chromium
"
){
const
t
=
e
&&
l
.
includes
(
e
)?
e
:
l
[
0
];
let
o
=
u
.
get
(
t
);
return
o
||
(
o
=
function
(
e
){
if
(
"
webkit
"
===
e
)
return
f
(
"
webkit
"
);
if
(
"
firefox
"
===
e
)
return
f
(
"
firefox
"
);
return
p
?
f
(
"
chromium
"
):
function
(){
const
e
=
i
(
"
puppeteer
"
);
let
t
,
o
;
return
{
type
:
"
chromium
"
,
provider
:
"
puppeteer
"
,
async
open
(
n
,
r
,
s
){
t
=
await
e
.
launch
(
r
.
options
);
const
c
=
t
.
process
();
c
?
a
(
"
%s %o
"
,
c
.
spawnfile
,
r
.
options
):
a
(
"
%o
"
,
r
.
options
),
o
=
await
t
.
newPage
(),
o
.
on
(
"
console
"
,(
e
=>
{
s
.
emit
(
"
App.logAdded
"
,{
type
:
e
.
type
(),
args
:[
e
.
text
()]})})),
o
.
on
(
"
pageerror
"
,(
e
=>
{
s
.
emit
(
"
App.exceptionThrown
"
,
e
)})),
await
o
.
goto
(
r
.
url
||
n
),
await
o
.
waitFor
(
1
e3
)},
close
:()
=>
t
.
close
(),
screenshot
:(
e
=!
1
)
=>
o
.
screenshot
({
encoding
:
"
base64
"
,
fullPage
:
e
})}}()}(
t
),
u
.
set
(
t
,
o
)),
o
}
function
f
(
e
){
const
t
=
i
(
"
playwright
"
);
let
o
,
n
;
return
{
type
:
e
,
provider
:
"
playwright
"
,
async
open
(
r
,
s
,
c
){
o
=
await
t
[
e
].
launch
(
s
.
options
),
"
firefox
"
===
e
&&
(
s
.
contextOptions
.
isMobile
=!
1
),
a
(
`browser.newContext
${
JSON
.
stringify
(
s
.
contextOptions
)}
`
);
const
i
=
await
o
.
newContext
(
s
.
contextOptions
);
n
=
await
i
.
newPage
(),
n
.
on
(
"
console
"
,(
e
=>
{
c
.
emit
(
"
App.logAdded
"
,{
type
:
e
.
type
(),
args
:[
e
.
text
()]})})),
n
.
on
(
"
pageerror
"
,(
e
=>
{
c
.
emit
(
"
App.exceptionThrown
"
,
e
)})),
await
n
.
goto
(
s
.
url
||
r
),
await
n
.
waitForTimeout
(
1
e3
)},
close
:()
=>
o
.
close
(),
screenshot
:(
e
=!
1
)
=>
n
.
screenshot
({
fullPage
:
e
}).
then
((
e
=>
e
.
toString
(
"
base64
"
)))}}
let
w
;
const
d
=
{
"
Tool.close
"
:{
reflect
:
async
()
=>
{
await
w
.
close
()}},
"
App.exit
"
:{
reflect
:
async
()
=>
{}},
"
App.enableLog
"
:{
reflect
:()
=>
Promise
.
resolve
()},
"
App.captureScreenshot
"
:{
reflect
:
async
(
e
,
t
)
=>
{
const
o
=
await
w
.
screenshot
(
!!
t
.
fullPage
);
return
a
(
`App.captureScreenshot
${
o
.
length
}
`
),{
data
:
o
}}}};
!
function
(
e
){
c
.
forEach
((
t
=>
{
e
[
t
]
=
function
(
e
){
return
{
reflect
:
async
(
t
,
o
)
=>
t
(
e
,
o
,
!
1
),
params
:
e
=>
(
e
.
selector
&&
(
e
.
selector
=
r
.
default
(
s
).
processSync
(
e
.
selector
)),
e
)}}(
t
)}))}(
d
);
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
,
n
)
=>
{
const
{
exec
:
r
}
=
require
(
"
node:child_process
"
);
/^win/
.
test
(
process
.
platform
)?(
r
(
`start
${
t
.
executablePath
}
${
e
}
`
,(
e
=>
{
if
(
e
)
throw
console
.
error
(
`open
${
t
.
executablePath
}
fail,
${
e
}
`
),
Error
(
e
)})),
setTimeout
((()
=>
{
o
(
null
)}),
1
e3
)):
r
(
`open -a "
${
t
.
executablePath
}
"
${
e
}
`
,(
e
=>
{
e
&&
(
console
.
error
(
`open
${
t
.
executablePath
}
fail,
${
e
}
`
),
n
(
e
)),
o
(
null
)}))})):(
w
=
h
(
process
.
env
.
BROWSER
),
a
(
"
createDevtools
"
+
(
w
.
provider
+
"
"
+
w
.
type
+
"
"
+
JSON
.
stringify
(
t
))),
await
w
.
open
(
e
,
t
,
o
))}},
shouldCompile
:(
e
,
t
)
=>!
t
.
url
,
adapter
:
d
};
module
.
exports
=
g
;
"
use strict
"
;
var
e
=
require
(
"
debug
"
),
t
=
require
(
"
postcss-selector-parser
"
);
function
o
(
e
){
return
e
&&
"
object
"
==
typeof
e
&&
"
default
"
in
e
?
e
:{
default
:
e
}}
var
n
=
o
(
e
),
r
=
o
(
t
);
const
a
=
n
.
default
(
"
automator:devtool
"
);
function
s
(
e
){
e
.
walk
((
e
=>
{
if
(
"
tag
"
===
e
.
type
){
const
t
=
e
.
value
;
e
.
value
=
"
page
"
===
t
?
"
uni-page-body
"
:
"
uni-
"
+
t
}}))}
const
i
=
[
"
Page.getElement
"
,
"
Page.getElements
"
,
"
Element.getElement
"
,
"
Element.getElements
"
];
function
c
(
e
){
try
{
return
require
(
e
)}
catch
(
t
){
return
require
(
require
.
resolve
(
e
,{
paths
:[
process
.
cwd
()]}))}}
/^win/
.
test
(
process
.
platform
);
const
l
=
[
"
chromium
"
,
"
firefox
"
,
"
webkit
"
];
let
p
=!
1
;
try
{
p
=!!
c
(
"
playwright
"
)}
catch
(
e
){}
const
u
=
new
Map
;
function
h
(
e
=
"
chromium
"
){
const
t
=
e
&&
l
.
includes
(
e
)?
e
:
l
[
0
];
let
o
=
u
.
get
(
t
);
return
o
||
(
o
=
function
(
e
){
if
(
"
webkit
"
===
e
)
return
f
(
"
webkit
"
);
if
(
"
firefox
"
===
e
)
return
f
(
"
firefox
"
);
return
p
?
f
(
"
chromium
"
):
function
(){
const
e
=
c
(
"
puppeteer
"
);
let
t
,
o
;
return
{
type
:
"
chromium
"
,
provider
:
"
puppeteer
"
,
async
open
(
n
,
r
,
s
){
t
=
await
e
.
launch
(
r
.
options
);
const
i
=
t
.
process
();
i
?
a
(
"
%s %o
"
,
i
.
spawnfile
,
r
.
options
):
a
(
"
%o
"
,
r
.
options
),
o
=
await
t
.
newPage
(),
o
.
on
(
"
console
"
,(
e
=>
{
s
.
emit
(
"
App.logAdded
"
,{
type
:
e
.
type
(),
args
:[
e
.
text
()]})})),
o
.
on
(
"
pageerror
"
,(
e
=>
{
s
.
emit
(
"
App.exceptionThrown
"
,
e
)})),
await
o
.
goto
(
r
.
url
||
n
),
await
o
.
waitFor
(
1
e3
)},
close
:()
=>
t
.
close
(),
screenshot
:(
e
=!
1
)
=>
o
.
screenshot
({
encoding
:
"
base64
"
,
fullPage
:
e
})}}()}(
t
),
u
.
set
(
t
,
o
)),
o
}
function
f
(
e
){
const
t
=
c
(
"
playwright
"
);
let
o
,
n
;
return
{
type
:
e
,
provider
:
"
playwright
"
,
async
open
(
r
,
s
,
i
){
o
=
await
t
[
e
].
launch
(
s
.
options
),
"
firefox
"
===
e
&&
(
s
.
contextOptions
.
isMobile
=!
1
),
a
(
`browser.newContext
${
JSON
.
stringify
(
s
.
contextOptions
)}
`
);
const
c
=
await
o
.
newContext
(
s
.
contextOptions
);
n
=
await
c
.
newPage
(),
n
.
on
(
"
console
"
,(
e
=>
{
i
.
emit
(
"
App.logAdded
"
,{
type
:
e
.
type
(),
args
:[
e
.
text
()]})})),
n
.
on
(
"
pageerror
"
,(
e
=>
{
i
.
emit
(
"
App.exceptionThrown
"
,
e
)})),
await
n
.
goto
(
s
.
url
||
r
),
await
n
.
waitForTimeout
(
1
e3
)},
close
:()
=>
o
.
close
(),
screenshot
:(
e
=!
1
)
=>
n
.
screenshot
({
fullPage
:
e
}).
then
((
e
=>
e
.
toString
(
"
base64
"
)))}}
let
w
;
const
d
=
{
"
Tool.close
"
:{
reflect
:
async
()
=>
{
await
w
.
close
()}},
"
App.exit
"
:{
reflect
:
async
()
=>
{}},
"
App.enableLog
"
:{
reflect
:()
=>
Promise
.
resolve
()},
"
App.captureScreenshot
"
:{
reflect
:
async
(
e
,
t
)
=>
{
const
o
=
await
w
.
screenshot
(
!!
t
.
fullPage
);
return
a
(
`App.captureScreenshot
${
o
.
length
}
`
),{
data
:
o
}}}};
!
function
(
e
){
i
.
forEach
((
t
=>
{
e
[
t
]
=
function
(
e
){
return
{
reflect
:
async
(
t
,
o
)
=>
t
(
e
,
o
,
!
1
),
params
:
e
=>
(
e
.
selector
&&
(
e
.
selector
=
r
.
default
(
s
).
processSync
(
e
.
selector
)),
e
)}}(
t
)}))}(
d
);
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
,
n
)
=>
{
const
{
exec
:
r
}
=
require
(
"
node:child_process
"
);
/^win/
.
test
(
process
.
platform
)?(
r
(
`start
${
t
.
executablePath
}
--user-data-dir=''
${
e
}
`
,(
e
=>
{
if
(
e
)
throw
console
.
error
(
`open
${
t
.
executablePath
}
fail,
${
e
}
`
),
Error
(
e
)})),
setTimeout
((()
=>
{
o
(
null
)}),
1
e3
)):
r
(
`open -a "
${
t
.
executablePath
}
"
${
e
}
`
,(
e
=>
{
e
&&
(
console
.
error
(
`open
${
t
.
executablePath
}
fail,
${
e
}
`
),
n
(
e
)),
o
(
null
)}))})):(
w
=
h
(
process
.
env
.
BROWSER
),
a
(
"
createDevtools
"
+
(
w
.
provider
+
"
"
+
w
.
type
+
"
"
+
JSON
.
stringify
(
t
))),
await
w
.
open
(
e
,
t
,
o
))}},
shouldCompile
:(
e
,
t
)
=>!
t
.
url
,
adapter
:
d
};
module
.
exports
=
g
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录