mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-11 10:00:23 +08:00
Merge branch 'master' into session_refactor
This commit is contained in:
@@ -1 +1 @@
|
||||
v5.0.0-250721
|
||||
v5.0.0-250723
|
||||
|
||||
@@ -31,7 +31,9 @@ func (dExt *XTDriver) LoopUntil(findAction, findCondition, foundAction Action, o
|
||||
}
|
||||
|
||||
if err := findAction(dExt); err != nil {
|
||||
// find action failed, abort loop
|
||||
log.Error().Err(err).Msgf("find action failed")
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +87,8 @@ func prepareSwipeAction(dExt *XTDriver, params interface{}, opts ...option.Actio
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("invalid swipe params %v", swipeDirection)
|
||||
return errors.Wrap(code.InvalidParamError,
|
||||
fmt.Sprintf("invalid swipe params %v", swipeDirection))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -97,7 +100,7 @@ func (dExt *XTDriver) SwipeToTapTexts(texts []string, opts ...option.ActionOptio
|
||||
}
|
||||
|
||||
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), option.WithInterval(1))
|
||||
|
||||
// Remove identifier for swipe operations to avoid WDA/UIA2 logging
|
||||
actionOptions := option.NewActionOptions(opts...)
|
||||
@@ -160,6 +163,7 @@ func (dExt *XTDriver) SwipeToTapApp(appName string, opts ...option.ActionOption)
|
||||
// swipe to first screen
|
||||
for i := 0; i < 5; i++ {
|
||||
dExt.Swipe(0.5, 0.5, 0.9, 0.5, optionsWithoutIdentifier...)
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
|
||||
opts = append(opts, option.WithDirection("left"))
|
||||
|
||||
@@ -183,6 +183,8 @@ func (s *DriverSession) RequestWithRetry(method string, urlStr string, rawBody [
|
||||
maxRetry = options.MaxRetryTimes
|
||||
}
|
||||
|
||||
synthesizeEventRetryAdded := false
|
||||
|
||||
for attempt := 1; attempt <= maxRetry; attempt++ {
|
||||
// Execute the request
|
||||
rawResp, err = s.Request(method, urlStr, rawBody, opts...)
|
||||
@@ -193,14 +195,22 @@ func (s *DriverSession) RequestWithRetry(method string, urlStr string, rawBody [
|
||||
return rawResp, nil
|
||||
}
|
||||
|
||||
// only for WDA driver, check if "synthesizeEvent timeout" error and add extra retry
|
||||
if strings.Contains(err.Error(), "synthesizeEvent timeout") && !synthesizeEventRetryAdded {
|
||||
log.Warn().Err(err).Msg("synthesizeEvent timeout detected, adding one extra retry")
|
||||
maxRetry++
|
||||
synthesizeEventRetryAdded = true
|
||||
}
|
||||
|
||||
// Notice: use DeviceHTTPDriverError when request driver failed
|
||||
lastError = errors.Wrap(code.DeviceHTTPDriverError, err.Error())
|
||||
log.Warn().Err(err).Msgf("request failed, attempt %d/%d", attempt, s.maxRetry)
|
||||
|
||||
// If this was the last attempt, break
|
||||
if attempt == s.maxRetry {
|
||||
log.Error().Err(lastError).Msgf("all %d retry attempts failed, giving up", s.maxRetry)
|
||||
if attempt == maxRetry {
|
||||
log.Error().Err(lastError).Msgf("request failed after %d retries, giving up", maxRetry)
|
||||
break
|
||||
} else {
|
||||
log.Warn().Err(lastError).Msgf("request failed after %d/%d retries, retrying", attempt, maxRetry)
|
||||
}
|
||||
|
||||
// Wait before next attempt
|
||||
|
||||
Reference in New Issue
Block a user