fix: 安装截图改为异步,避免截图时间过长导致来不及点击小米弹窗

This commit is contained in:
余泓铮
2025-02-24 12:09:14 +08:00
parent f0ee822ad7
commit b64a8ea518

View File

@@ -1,7 +1,7 @@
package driver_ext
import (
"fmt"
"github.com/rs/zerolog/log"
"time"
"github.com/httprunner/httprunner/v5/pkg/uixt"
@@ -48,15 +48,17 @@ func (dExt *XTDriver) Install(filePath string, opts ...option.InstallOption) err
if _, ok := dExt.GetDevice().(*uixt.AndroidDevice); ok {
stopChan := make(chan struct{})
go func() {
ticker := time.NewTicker(5 * time.Second)
ticker := time.NewTicker(3 * time.Second)
defer ticker.Stop()
for {
select {
case <-ticker.C:
_ = dExt.TapByOCR("^(.*无视风险安装|正在扫描.*|我知道了|稍后继续|稍后提醒|继续安装|知道了|确定|继续|完成|点击继续安装|继续安装旧版本|替换|.*正在安装|安装|授权本次安装|重新安装|仍要安装|更多详情|我知道了|已了解此应用未经检测.)$", option.WithRegex(true), option.WithIgnoreNotFoundError(true))
go func() {
_ = dExt.TapByOCR("^(.*无视风险安装|正在扫描.*|我知道了|稍后继续|稍后提醒|继续安装|知道了|确定|继续|完成|点击继续安装|继续安装旧版本|替换|.*正在安装|安装|授权本次安装|重新安装|仍要安装|更多详情|我知道了|已了解此应用未经检测.)$", option.WithRegex(true), option.WithIgnoreNotFoundError(true))
}()
case <-stopChan:
fmt.Println("Ticker stopped")
log.Info().Msg("install complete")
return
}
}