mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-07 05:32:43 +08:00
change: RoundToOneDecimal
This commit is contained in:
@@ -374,6 +374,11 @@ func ConvertToStringSlice(val interface{}) ([]string, error) {
|
||||
return stringSlice, nil
|
||||
}
|
||||
|
||||
// RoundToOneDecimal rounds a float64 value to 1 decimal place
|
||||
func RoundToOneDecimal(val float64) float64 {
|
||||
return math.Round(val*10) / 10.0
|
||||
}
|
||||
|
||||
func GetFreePort() (int, error) {
|
||||
minPort := 20000
|
||||
maxPort := 50000
|
||||
|
||||
@@ -1 +1 @@
|
||||
v5.0.0-beta-2506051652
|
||||
v5.0.0-beta-2506051747
|
||||
|
||||
@@ -3,13 +3,13 @@ package ai
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/cloudwego/eino/schema"
|
||||
"github.com/httprunner/httprunner/v5/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v5/uixt/option"
|
||||
"github.com/httprunner/httprunner/v5/uixt/types"
|
||||
"github.com/rs/zerolog/log"
|
||||
@@ -167,9 +167,9 @@ func normalizeCoordinatesFormat(text string) string {
|
||||
// - Y conversion: 500/1000 * 1080 = 540 pixels
|
||||
func convertRelativeToAbsolute(relativeCoord float64, isXCoord bool, size types.Size) float64 {
|
||||
if isXCoord {
|
||||
return math.Round((relativeCoord/DefaultFactor*float64(size.Width))*10) / 10
|
||||
return builtin.RoundToOneDecimal(relativeCoord / DefaultFactor * float64(size.Width))
|
||||
}
|
||||
return math.Round((relativeCoord/DefaultFactor*float64(size.Height))*10) / 10
|
||||
return builtin.RoundToOneDecimal(relativeCoord / DefaultFactor * float64(size.Height))
|
||||
}
|
||||
|
||||
// parseActionTypeAndArguments extracts function name and raw parameter map from action string
|
||||
@@ -280,10 +280,10 @@ func convertProcessedArgs(processedArgs map[string]interface{}, actionType strin
|
||||
}
|
||||
|
||||
options := option.ActionOptions{
|
||||
FromX: startCoords[0],
|
||||
FromY: startCoords[1],
|
||||
ToX: endCoords[0],
|
||||
ToY: endCoords[1],
|
||||
FromX: builtin.RoundToOneDecimal(startCoords[0]),
|
||||
FromY: builtin.RoundToOneDecimal(startCoords[1]),
|
||||
ToX: builtin.RoundToOneDecimal(endCoords[0]),
|
||||
ToY: builtin.RoundToOneDecimal(endCoords[1]),
|
||||
}
|
||||
return options.ToMap(), nil
|
||||
}
|
||||
@@ -295,8 +295,8 @@ func convertProcessedArgs(processedArgs map[string]interface{}, actionType strin
|
||||
return nil, fmt.Errorf("invalid coordinate format for single operation")
|
||||
}
|
||||
options := option.ActionOptions{
|
||||
X: startCoords[0],
|
||||
Y: startCoords[1],
|
||||
X: builtin.RoundToOneDecimal(startCoords[0]),
|
||||
Y: builtin.RoundToOneDecimal(startCoords[1]),
|
||||
}
|
||||
return options.ToMap(), nil
|
||||
}
|
||||
|
||||
@@ -25,6 +25,12 @@ func (dExt *XTDriver) StartToGoal(text string, opts ...option.ActionOption) erro
|
||||
attempt++
|
||||
log.Info().Int("attempt", attempt).Msg("planning attempt")
|
||||
if err := dExt.AIAction(text, opts...); err != nil {
|
||||
// Check if this is a LLM service request error that should be retried
|
||||
if errors.Is(err, code.LLMRequestServiceError) {
|
||||
log.Warn().Err(err).Int("attempt", attempt).
|
||||
Msg("LLM service request failed, retrying...")
|
||||
continue
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"math/rand/v2"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -53,8 +52,8 @@ func convertToAbsolutePoint(driver IDriver, x, y float64) (absX, absY float64, e
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
absX = math.Round(float64(windowSize.Width)*x*10) / 10
|
||||
absY = math.Round(float64(windowSize.Height)*y*10) / 10
|
||||
absX = builtin.RoundToOneDecimal(float64(windowSize.Width) * x)
|
||||
absY = builtin.RoundToOneDecimal(float64(windowSize.Height) * y)
|
||||
return absX, absY, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
builtinJSON "encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -667,10 +666,10 @@ func (wd *WDADriver) Drag(fromX, fromY, toX, toY float64, opts ...option.ActionO
|
||||
defer postHandler(wd, option.ACTION_Drag, actionOptions)
|
||||
|
||||
data := map[string]interface{}{
|
||||
"fromX": math.Round(fromX*10) / 10,
|
||||
"fromY": math.Round(fromY*10) / 10,
|
||||
"toX": math.Round(toX*10) / 10,
|
||||
"toY": math.Round(toY*10) / 10,
|
||||
"fromX": builtin.RoundToOneDecimal(fromX),
|
||||
"fromY": builtin.RoundToOneDecimal(fromY),
|
||||
"toX": builtin.RoundToOneDecimal(toX),
|
||||
"toY": builtin.RoundToOneDecimal(toY),
|
||||
}
|
||||
option.MergeOptions(data, opts...)
|
||||
// wda 43 version
|
||||
|
||||
Reference in New Issue
Block a user