mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
optimize hrp summary popup info
This commit is contained in:
@@ -59,15 +59,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "处理青少年弹窗 tap ocr 以及 ui_ocr exists 断言",
|
"name": "处理弹窗 close_popups 默认配置 以及 ui_ocr exists 断言",
|
||||||
"android": {
|
"android": {
|
||||||
"actions": [
|
"actions": [
|
||||||
{
|
{
|
||||||
"method": "tap_ocr",
|
"method": "close_popups",
|
||||||
"params": "我知道了",
|
"options": {}
|
||||||
"options": {
|
|
||||||
"ignore_NotFoundError": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -317,14 +314,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "处理青少年弹窗 tap ocr 以及 ui_ocr exists 断言",
|
"name": "处理弹窗 close_popups 自定义配置 以及 ui_ocr exists 断言",
|
||||||
"android": {
|
"android": {
|
||||||
"actions": [
|
"actions": [
|
||||||
{
|
{
|
||||||
"method": "tap_ocr",
|
"method": "close_popups",
|
||||||
"params": "我知道了",
|
|
||||||
"options": {
|
"options": {
|
||||||
"ignore_NotFoundError": true
|
"max_retry_times": 3,
|
||||||
|
"interval": 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
//go:build localtest
|
|
||||||
|
|
||||||
package uitest
|
package uitest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -36,12 +34,9 @@ func TestAndroidExpertTest(t *testing.T) {
|
|||||||
Home().
|
Home().
|
||||||
SwipeToTapApp("$app_name").
|
SwipeToTapApp("$app_name").
|
||||||
Sleep(10),
|
Sleep(10),
|
||||||
hrp.NewStep("处理青少年弹窗 tap ocr 以及 ui_ocr exists 断言").
|
hrp.NewStep("处理弹窗 close_popups 默认配置 以及 ui_ocr exists 断言").
|
||||||
Android().
|
Android().
|
||||||
TapByOCR(
|
ClosePopups().
|
||||||
"我知道了",
|
|
||||||
uixt.WithIgnoreNotFoundError(true),
|
|
||||||
).
|
|
||||||
Validate().
|
Validate().
|
||||||
AssertOCRExists("推荐", "进入抖音失败"),
|
AssertOCRExists("推荐", "进入抖音失败"),
|
||||||
// 直播赛道
|
// 直播赛道
|
||||||
@@ -118,11 +113,11 @@ func TestAndroidExpertTest(t *testing.T) {
|
|||||||
Home().
|
Home().
|
||||||
SwipeToTapApp("$app_name", uixt.WithMaxRetryTimes(5), uixt.WithInterval(1), uixt.WithOffset(0, -50)).
|
SwipeToTapApp("$app_name", uixt.WithMaxRetryTimes(5), uixt.WithInterval(1), uixt.WithOffset(0, -50)).
|
||||||
Sleep(10),
|
Sleep(10),
|
||||||
hrp.NewStep("处理青少年弹窗 tap ocr 以及 ui_ocr exists 断言").
|
hrp.NewStep("处理弹窗 close_popups 自定义配置 以及 ui_ocr exists 断言").
|
||||||
Android().
|
Android().
|
||||||
TapByOCR(
|
ClosePopups(
|
||||||
"我知道了",
|
uixt.WithMaxRetryTimes(3),
|
||||||
uixt.WithIgnoreNotFoundError(true),
|
uixt.WithInterval(2),
|
||||||
).
|
).
|
||||||
Validate().
|
Validate().
|
||||||
AssertOCRExists("推荐", "进入抖音失败"),
|
AssertOCRExists("推荐", "进入抖音失败"),
|
||||||
@@ -194,12 +189,9 @@ func TestIOSExpertTest(t *testing.T) {
|
|||||||
Home().
|
Home().
|
||||||
SwipeToTapApp("$app_name").
|
SwipeToTapApp("$app_name").
|
||||||
Sleep(10),
|
Sleep(10),
|
||||||
hrp.NewStep("处理青少年弹窗 tap ocr 以及 ui_ocr exists 断言").
|
hrp.NewStep("处理弹窗 close_popups 默认配置 以及 ui_ocr exists 断言").
|
||||||
IOS().
|
IOS().
|
||||||
TapByOCR(
|
ClosePopups().
|
||||||
"我知道了",
|
|
||||||
uixt.WithIgnoreNotFoundError(true),
|
|
||||||
).
|
|
||||||
Validate().
|
Validate().
|
||||||
AssertOCRExists("推荐", "进入抖音失败"),
|
AssertOCRExists("推荐", "进入抖音失败"),
|
||||||
// 直播赛道
|
// 直播赛道
|
||||||
@@ -275,11 +267,11 @@ func TestIOSExpertTest(t *testing.T) {
|
|||||||
Home().
|
Home().
|
||||||
SwipeToTapApp("$app_name", uixt.WithMaxRetryTimes(5), uixt.WithInterval(1), uixt.WithOffset(0, -50)).
|
SwipeToTapApp("$app_name", uixt.WithMaxRetryTimes(5), uixt.WithInterval(1), uixt.WithOffset(0, -50)).
|
||||||
Sleep(10),
|
Sleep(10),
|
||||||
hrp.NewStep("处理青少年弹窗 tap ocr 以及 ui_ocr exists 断言").
|
hrp.NewStep("处理弹窗 close_popups 自定义配置 以及 ui_ocr exists 断言").
|
||||||
IOS().
|
IOS().
|
||||||
TapByOCR(
|
ClosePopups(
|
||||||
"我知道了",
|
uixt.WithMaxRetryTimes(3),
|
||||||
uixt.WithIgnoreNotFoundError(true),
|
uixt.WithInterval(2),
|
||||||
).
|
).
|
||||||
Validate().
|
Validate().
|
||||||
AssertOCRExists("推荐", "进入抖音失败"),
|
AssertOCRExists("推荐", "进入抖音失败"),
|
||||||
|
|||||||
@@ -52,15 +52,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "处理青少年弹窗 tap ocr 以及 ui_ocr exists 断言",
|
"name": "处理弹窗 close_popups 默认配置 以及 ui_ocr exists 断言",
|
||||||
"ios": {
|
"ios": {
|
||||||
"actions": [
|
"actions": [
|
||||||
{
|
{
|
||||||
"method": "tap_ocr",
|
"method": "close_popups",
|
||||||
"params": "我知道了",
|
"options": {}
|
||||||
"options": {
|
|
||||||
"ignore_NotFoundError": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -302,14 +299,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "处理青少年弹窗 tap ocr 以及 ui_ocr exists 断言",
|
"name": "处理弹窗 close_popups 自定义配置 以及 ui_ocr exists 断言",
|
||||||
"ios": {
|
"ios": {
|
||||||
"actions": [
|
"actions": [
|
||||||
{
|
{
|
||||||
"method": "tap_ocr",
|
"method": "close_popups",
|
||||||
"params": "我知道了",
|
|
||||||
"options": {
|
"options": {
|
||||||
"ignore_NotFoundError": true
|
"max_retry_times": 3,
|
||||||
|
"interval": 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
+11
-11
@@ -115,11 +115,11 @@ type ActionOptions struct {
|
|||||||
Custom map[string]interface{} `json:"custom,omitempty" yaml:"custom,omitempty"`
|
Custom map[string]interface{} `json:"custom,omitempty" yaml:"custom,omitempty"`
|
||||||
|
|
||||||
// screenshot related
|
// screenshot related
|
||||||
ScreenShotWithOCR bool `json:"screenshot_with_ocr,omitempty" yaml:"screenshot_with_ocr,omitempty"`
|
ScreenShotWithOCR bool `json:"screenshot_with_ocr,omitempty" yaml:"screenshot_with_ocr,omitempty"`
|
||||||
ScreenShotWithUpload bool `json:"screenshot_with_upload,omitempty" yaml:"screenshot_with_upload,omitempty"`
|
ScreenShotWithUpload bool `json:"screenshot_with_upload,omitempty" yaml:"screenshot_with_upload,omitempty"`
|
||||||
ScreenShotWithLiveType bool `json:"screenshot_with_live_type,omitempty" yaml:"screenshot_with_live_type,omitempty"`
|
ScreenShotWithLiveType bool `json:"screenshot_with_live_type,omitempty" yaml:"screenshot_with_live_type,omitempty"`
|
||||||
ScreenShotWithUITypes []string `json:"screenshot_with_ui_types,omitempty" yaml:"screenshot_with_ui_types,omitempty"`
|
ScreenShotWithUITypes []string `json:"screenshot_with_ui_types,omitempty" yaml:"screenshot_with_ui_types,omitempty"`
|
||||||
ScreenShotWithClose bool `json:"screenshot_with_close,omitempty" yaml:"screenshot_with_close,omitempty"`
|
ScreenShotWithClosePopups bool `json:"screenshot_with_close_popups,omitempty" yaml:"screenshot_with_close_popups,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ActionOptions) Options() []ActionOption {
|
func (o *ActionOptions) Options() []ActionOption {
|
||||||
@@ -219,12 +219,12 @@ func (o *ActionOptions) Options() []ActionOption {
|
|||||||
|
|
||||||
func (o *ActionOptions) screenshotActions() []string {
|
func (o *ActionOptions) screenshotActions() []string {
|
||||||
actions := []string{}
|
actions := []string{}
|
||||||
if o.ScreenShotWithOCR {
|
|
||||||
actions = append(actions, "ocr")
|
|
||||||
}
|
|
||||||
if o.ScreenShotWithUpload {
|
if o.ScreenShotWithUpload {
|
||||||
actions = append(actions, "upload")
|
actions = append(actions, "upload")
|
||||||
}
|
}
|
||||||
|
if o.ScreenShotWithOCR {
|
||||||
|
actions = append(actions, "ocr")
|
||||||
|
}
|
||||||
if o.ScreenShotWithLiveType {
|
if o.ScreenShotWithLiveType {
|
||||||
actions = append(actions, "liveType")
|
actions = append(actions, "liveType")
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,7 @@ func (o *ActionOptions) screenshotActions() []string {
|
|||||||
if len(o.ScreenShotWithUITypes) > 0 {
|
if len(o.ScreenShotWithUITypes) > 0 {
|
||||||
actions = append(actions, "ui")
|
actions = append(actions, "ui")
|
||||||
}
|
}
|
||||||
if o.ScreenShotWithClose {
|
if o.ScreenShotWithClosePopups {
|
||||||
actions = append(actions, "close")
|
actions = append(actions, "close")
|
||||||
}
|
}
|
||||||
return actions
|
return actions
|
||||||
@@ -443,9 +443,9 @@ func WithScreenShotUITypes(uiTypes ...string) ActionOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithScreenShotClose(closeOn bool) ActionOption {
|
func WithScreenShotClosePopups(closeOn bool) ActionOption {
|
||||||
return func(o *ActionOptions) {
|
return func(o *ActionOptions) {
|
||||||
o.ScreenShotWithClose = closeOn
|
o.ScreenShotWithClosePopups = closeOn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+53
-10
@@ -15,6 +15,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
@@ -61,7 +62,7 @@ type ScreenResult struct {
|
|||||||
VideoType string `json:"video_type,omitempty"` // video type: feed, live-preview or live
|
VideoType string `json:"video_type,omitempty"` // video type: feed, live-preview or live
|
||||||
Feed *FeedVideo `json:"feed,omitempty"`
|
Feed *FeedVideo `json:"feed,omitempty"`
|
||||||
Live *LiveRoom `json:"live,omitempty"`
|
Live *LiveRoom `json:"live,omitempty"`
|
||||||
Popup *CPResult `json:"popup,omitempty"`
|
Popup *PopupInfo `json:"popup,omitempty"`
|
||||||
|
|
||||||
SwipeStartTime int64 `json:"swipe_start_time"` // 滑动开始时间戳
|
SwipeStartTime int64 `json:"swipe_start_time"` // 滑动开始时间戳
|
||||||
SwipeFinishTime int64 `json:"swipe_finish_time"` // 滑动结束时间戳
|
SwipeFinishTime int64 `json:"swipe_finish_time"` // 滑动结束时间戳
|
||||||
@@ -73,11 +74,58 @@ type ScreenResult struct {
|
|||||||
TotalElapsed int64 `json:"total_elapsed"` // current_swipe_finish -> next_swipe_start 整体耗时(ms)
|
TotalElapsed int64 `json:"total_elapsed"` // current_swipe_finish -> next_swipe_start 整体耗时(ms)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ScreenResultMap map[string]*ScreenResult
|
||||||
|
|
||||||
|
// getScreenShotUrls returns screenShotsUrls using imagePath as key and uploaded URL as value
|
||||||
|
func (screenResults ScreenResultMap) getScreenShotUrls() map[string]string {
|
||||||
|
screenShotsUrls := make(map[string]string)
|
||||||
|
for imagePath, screenResult := range screenResults {
|
||||||
|
if screenResult.UploadedURL == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
screenShotsUrls[imagePath] = screenResult.UploadedURL
|
||||||
|
}
|
||||||
|
return screenShotsUrls
|
||||||
|
}
|
||||||
|
|
||||||
|
// checkPopupInfo checks if popup closed normally in every screenResult with close_popups on:
|
||||||
|
func (screenResults ScreenResultMap) checkPopupInfo() {
|
||||||
|
var screenResultList []*ScreenResult
|
||||||
|
for _, screenResult := range screenResults {
|
||||||
|
if screenResult.Popup == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
screenResultList = append(screenResultList, screenResult)
|
||||||
|
}
|
||||||
|
if len(screenResultList) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
sort.Slice(screenResultList, func(i, j int) bool {
|
||||||
|
return screenResultList[i].Popup.RetryCount < screenResultList[j].Popup.RetryCount
|
||||||
|
})
|
||||||
|
|
||||||
|
for i := 0; i < len(screenResultList)-1; i++ {
|
||||||
|
curPopup := screenResultList[i].Popup
|
||||||
|
nextPopup := screenResultList[i+1].Popup
|
||||||
|
|
||||||
|
// popup not existed, no need to close
|
||||||
|
if curPopup.CloseArea.IsEmpty() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// popup existed, but identical popups occurs during next retry
|
||||||
|
if curPopup.Text == nextPopup.Text && curPopup.Type == nextPopup.Type {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// popup existed, but no popup or different popup occurs during next retry (IsClosed=true)
|
||||||
|
screenResultList[i].Popup.IsClosed = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type cacheStepData struct {
|
type cacheStepData struct {
|
||||||
// cache step screenshot paths
|
// cache step screenshot paths
|
||||||
screenShots []string
|
screenShots []string
|
||||||
// cache step screenshot ocr results, key is image path, value is ScreenResult
|
// cache step screenshot ocr results, key is image path, value is ScreenResult
|
||||||
screenResults map[string]*ScreenResult
|
screenResults ScreenResultMap
|
||||||
// cache feed/live video stat
|
// cache feed/live video stat
|
||||||
videoCrawler *VideoCrawler
|
videoCrawler *VideoCrawler
|
||||||
}
|
}
|
||||||
@@ -224,14 +272,8 @@ func (dExt *DriverExt) GetStepCacheData() map[string]interface{} {
|
|||||||
cacheData["video_stat"] = dExt.cacheStepData.videoCrawler
|
cacheData["video_stat"] = dExt.cacheStepData.videoCrawler
|
||||||
cacheData["screenshots"] = dExt.cacheStepData.screenShots
|
cacheData["screenshots"] = dExt.cacheStepData.screenShots
|
||||||
|
|
||||||
screenShotsUrls := make(map[string]string)
|
cacheData["screenshots_urls"] = dExt.cacheStepData.screenResults.getScreenShotUrls()
|
||||||
for imagePath, screenResult := range dExt.cacheStepData.screenResults {
|
dExt.cacheStepData.screenResults.checkPopupInfo()
|
||||||
if screenResult.UploadedURL == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
screenShotsUrls[imagePath] = screenResult.UploadedURL
|
|
||||||
}
|
|
||||||
cacheData["screenshots_urls"] = screenShotsUrls
|
|
||||||
|
|
||||||
screenSize, err := dExt.Driver.WindowSize()
|
screenSize, err := dExt.Driver.WindowSize()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -256,6 +298,7 @@ func (dExt *DriverExt) GetStepCacheData() map[string]interface{} {
|
|||||||
"screenshot_take_elapsed": screenResult.ScreenshotTakeElapsed,
|
"screenshot_take_elapsed": screenResult.ScreenshotTakeElapsed,
|
||||||
"screenshot_cv_elapsed": screenResult.ScreenshotCVElapsed,
|
"screenshot_cv_elapsed": screenResult.ScreenshotCVElapsed,
|
||||||
"total_elapsed": screenResult.TotalElapsed,
|
"total_elapsed": screenResult.TotalElapsed,
|
||||||
|
"icons": screenResult.Icons,
|
||||||
"popup": screenResult.Popup,
|
"popup": screenResult.Popup,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/httprunner/funplugin"
|
"github.com/httprunner/funplugin"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -436,10 +434,6 @@ type PointF struct {
|
|||||||
Y float64 `json:"y"`
|
Y float64 `json:"y"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p PointF) IsOriginal() bool {
|
|
||||||
return builtin.IsZeroFloat64(p.X) && builtin.IsZeroFloat64(p.Y)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Rect struct {
|
type Rect struct {
|
||||||
Point
|
Point
|
||||||
Size
|
Size
|
||||||
|
|||||||
+17
-9
@@ -83,13 +83,14 @@ type CPResult struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PopupInfo struct {
|
type PopupInfo struct {
|
||||||
// TODO: support more types of popup report info
|
IsClosed bool `json:"is_closed"`
|
||||||
// Status bool `json:"status"`
|
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
|
Text string `json:"text"`
|
||||||
RetryCount int `json:"retry_count"`
|
RetryCount int `json:"retry_count"`
|
||||||
PicName string `json:"pic_name"`
|
PicName string `json:"pic_name"`
|
||||||
PicURL string `json:"pic_url"`
|
PicURL string `json:"pic_url"`
|
||||||
Point PointF `json:"point"`
|
PopupArea Box `json:"popup_area"`
|
||||||
|
CloseArea Box `json:"close_area"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dExt *DriverExt) ClosePopups(options ...ActionOption) error {
|
func (dExt *DriverExt) ClosePopups(options ...ActionOption) error {
|
||||||
@@ -111,9 +112,9 @@ func (dExt *DriverExt) ClosePopupsHandler(options ...ActionOption) error {
|
|||||||
maxRetryTimes := actionOptions.MaxRetryTimes
|
maxRetryTimes := actionOptions.MaxRetryTimes
|
||||||
interval := actionOptions.Interval
|
interval := actionOptions.Interval
|
||||||
|
|
||||||
for retryCount := 1; retryCount <= maxRetryTimes; retryCount++ {
|
for retryCount := 0; retryCount < maxRetryTimes; retryCount++ {
|
||||||
screenResult, err := dExt.GetScreenResult(
|
screenResult, err := dExt.GetScreenResult(
|
||||||
WithScreenShotClose(true), WithScreenShotUpload(true))
|
WithScreenShotClosePopups(true), WithScreenShotUpload(true))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("get screen result failed for popup handler")
|
log.Error().Err(err).Msg("get screen result failed for popup handler")
|
||||||
continue
|
continue
|
||||||
@@ -124,6 +125,10 @@ func (dExt *DriverExt) ClosePopupsHandler(options ...ActionOption) error {
|
|||||||
if screenResult.Popup == nil {
|
if screenResult.Popup == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
screenResult.Popup.RetryCount = retryCount
|
||||||
|
if screenResult.Popup.CloseArea.IsEmpty() {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
if err = dExt.tapPopupHandler(screenResult.Popup); err != nil {
|
if err = dExt.tapPopupHandler(screenResult.Popup); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -134,12 +139,15 @@ func (dExt *DriverExt) ClosePopupsHandler(options ...ActionOption) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dExt *DriverExt) tapPopupHandler(cpResult *CPResult) error {
|
func (dExt *DriverExt) tapPopupHandler(popup *PopupInfo) error {
|
||||||
if cpResult == nil {
|
if popup == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
log.Info().Str("type", cpResult.Type).Str("text", cpResult.Text).Msg("close popup")
|
if popup.CloseArea.IsEmpty() {
|
||||||
popupCenter := cpResult.CloseArea.Center()
|
return nil
|
||||||
|
}
|
||||||
|
log.Info().Str("type", popup.Type).Str("text", popup.Text).Msg("close popup")
|
||||||
|
popupCenter := popup.CloseArea.Center()
|
||||||
if err := dExt.TapAbsXY(popupCenter.X, popupCenter.Y); err != nil {
|
if err := dExt.TapAbsXY(popupCenter.X, popupCenter.Y); err != nil {
|
||||||
log.Error().Err(err).Msg("tap popup failed")
|
log.Error().Err(err).Msg("tap popup failed")
|
||||||
return errors.Wrap(code.MobileUIPopupError, err.Error())
|
return errors.Wrap(code.MobileUIPopupError, err.Error())
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@@ -356,7 +357,8 @@ type IImageService interface {
|
|||||||
// GetScreenResult takes a screenshot, returns the image recognization result
|
// GetScreenResult takes a screenshot, returns the image recognization result
|
||||||
func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *ScreenResult, err error) {
|
func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *ScreenResult, err error) {
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
fileName := builtin.GenNameWithTimestamp("%d_screenshot")
|
actionOptions := NewActionOptions(options...)
|
||||||
|
fileName := builtin.GenNameWithTimestamp("%d_" + strings.Join(actionOptions.screenshotActions(), "_"))
|
||||||
bufSource, imagePath, err := dExt.takeScreenShot(fileName)
|
bufSource, imagePath, err := dExt.takeScreenShot(fileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@@ -386,9 +388,17 @@ func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *S
|
|||||||
LiveType: imageResult.LiveType,
|
LiveType: imageResult.LiveType,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !imageResult.CPResult.CloseArea.IsEmpty() && !imageResult.CPResult.CloseArea.Point.IsOriginal() {
|
if actionOptions.ScreenShotWithClosePopups {
|
||||||
screenResult.Popup = &imageResult.CPResult
|
screenResult.Popup = &PopupInfo{
|
||||||
|
Type: imageResult.CPResult.Type,
|
||||||
|
Text: imageResult.CPResult.Text,
|
||||||
|
PicName: imagePath,
|
||||||
|
PicURL: imageResult.URL,
|
||||||
|
PopupArea: imageResult.CPResult.PopupArea,
|
||||||
|
CloseArea: imageResult.CPResult.CloseArea,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dExt.cacheStepData.screenResults[imagePath] = screenResult
|
dExt.cacheStepData.screenResults[imagePath] = screenResult
|
||||||
|
|||||||
@@ -327,6 +327,15 @@ func (s *StepMobile) StopCamera() *StepMobile {
|
|||||||
return &StepMobile{step: s.step}
|
return &StepMobile{step: s.step}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *StepMobile) ClosePopups(options ...uixt.ActionOption) *StepMobile {
|
||||||
|
s.mobileStep().Actions = append(s.mobileStep().Actions, uixt.MobileAction{
|
||||||
|
Method: uixt.ACTION_ClosePopups,
|
||||||
|
Params: nil,
|
||||||
|
Options: uixt.NewActionOptions(options...),
|
||||||
|
})
|
||||||
|
return &StepMobile{step: s.step}
|
||||||
|
}
|
||||||
|
|
||||||
// Validate switches to step validation.
|
// Validate switches to step validation.
|
||||||
func (s *StepMobile) Validate() *StepMobileUIValidation {
|
func (s *StepMobile) Validate() *StepMobileUIValidation {
|
||||||
return &StepMobileUIValidation{
|
return &StepMobileUIValidation{
|
||||||
|
|||||||
Reference in New Issue
Block a user