fix: Remove identifier for swipe operations to avoid WDA/UIA2 logging

This commit is contained in:
lilong.129
2025-07-04 18:34:27 +08:00
parent bfcaa71e6f
commit b5514ee460
+13 -3
View File
@@ -98,6 +98,12 @@ func (dExt *XTDriver) SwipeToTapTexts(texts []string, opts ...option.ActionOptio
log.Info().Strs("texts", texts).Msg("swipe to tap texts") log.Info().Strs("texts", texts).Msg("swipe to tap texts")
opts = append(opts, option.WithMatchOne(true), option.WithRegex(true)) opts = append(opts, option.WithMatchOne(true), option.WithRegex(true))
// Remove identifier for swipe operations to avoid WDA/UIA2 logging
actionOptions := option.NewActionOptions(opts...)
actionOptions.Identifier = ""
optionsWithoutIdentifier := actionOptions.Options()
var point ai.PointF var point ai.PointF
findTexts := func(d *XTDriver) error { findTexts := func(d *XTDriver) error {
var err error var err error
@@ -129,7 +135,7 @@ func (dExt *XTDriver) SwipeToTapTexts(texts []string, opts ...option.ActionOptio
return d.TapAbsXY(point.X, point.Y, opts...) return d.TapAbsXY(point.X, point.Y, opts...)
} }
findAction := prepareSwipeAction(dExt, nil, opts...) findAction := prepareSwipeAction(dExt, nil, optionsWithoutIdentifier...)
return dExt.LoopUntil(findAction, findTexts, foundTextAction, opts...) return dExt.LoopUntil(findAction, findTexts, foundTextAction, opts...)
} }
@@ -146,15 +152,19 @@ func (dExt *XTDriver) SwipeToTapApp(appName string, opts ...option.ActionOption)
log.Error().Err(err).Msg("auto handle popup failed") log.Error().Err(err).Msg("auto handle popup failed")
} }
// Remove identifier for swipe operations to avoid WDA/UIA2 logging
actionOptions := option.NewActionOptions(opts...)
actionOptions.Identifier = ""
optionsWithoutIdentifier := actionOptions.Options()
// swipe to first screen // swipe to first screen
for i := 0; i < 5; i++ { for i := 0; i < 5; i++ {
dExt.Swipe(0.5, 0.5, 0.9, 0.5, opts...) dExt.Swipe(0.5, 0.5, 0.9, 0.5, optionsWithoutIdentifier...)
} }
opts = append(opts, option.WithDirection("left")) opts = append(opts, option.WithDirection("left"))
opts = append(opts, option.WithMaxRetryTimes(5)) opts = append(opts, option.WithMaxRetryTimes(5))
actionOptions := option.NewActionOptions(opts...)
// tap app icon above the text // tap app icon above the text
if len(actionOptions.TapOffset) == 0 { if len(actionOptions.TapOffset) == 0 {
opts = append(opts, option.WithTapOffset(0, -100)) opts = append(opts, option.WithTapOffset(0, -100))