mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-06 07:57:27 +08:00
change: RoundToOneDecimal
This commit is contained in:
@@ -374,6 +374,11 @@ func ConvertToStringSlice(val interface{}) ([]string, error) {
|
|||||||
return stringSlice, nil
|
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) {
|
func GetFreePort() (int, error) {
|
||||||
minPort := 20000
|
minPort := 20000
|
||||||
maxPort := 50000
|
maxPort := 50000
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
v5.0.0-beta-2506051652
|
v5.0.0-beta-2506051747
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ package ai
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cloudwego/eino/schema"
|
"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/option"
|
||||||
"github.com/httprunner/httprunner/v5/uixt/types"
|
"github.com/httprunner/httprunner/v5/uixt/types"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
@@ -167,9 +167,9 @@ func normalizeCoordinatesFormat(text string) string {
|
|||||||
// - Y conversion: 500/1000 * 1080 = 540 pixels
|
// - Y conversion: 500/1000 * 1080 = 540 pixels
|
||||||
func convertRelativeToAbsolute(relativeCoord float64, isXCoord bool, size types.Size) float64 {
|
func convertRelativeToAbsolute(relativeCoord float64, isXCoord bool, size types.Size) float64 {
|
||||||
if isXCoord {
|
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
|
// 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{
|
options := option.ActionOptions{
|
||||||
FromX: startCoords[0],
|
FromX: builtin.RoundToOneDecimal(startCoords[0]),
|
||||||
FromY: startCoords[1],
|
FromY: builtin.RoundToOneDecimal(startCoords[1]),
|
||||||
ToX: endCoords[0],
|
ToX: builtin.RoundToOneDecimal(endCoords[0]),
|
||||||
ToY: endCoords[1],
|
ToY: builtin.RoundToOneDecimal(endCoords[1]),
|
||||||
}
|
}
|
||||||
return options.ToMap(), nil
|
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")
|
return nil, fmt.Errorf("invalid coordinate format for single operation")
|
||||||
}
|
}
|
||||||
options := option.ActionOptions{
|
options := option.ActionOptions{
|
||||||
X: startCoords[0],
|
X: builtin.RoundToOneDecimal(startCoords[0]),
|
||||||
Y: startCoords[1],
|
Y: builtin.RoundToOneDecimal(startCoords[1]),
|
||||||
}
|
}
|
||||||
return options.ToMap(), nil
|
return options.ToMap(), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,12 @@ func (dExt *XTDriver) StartToGoal(text string, opts ...option.ActionOption) erro
|
|||||||
attempt++
|
attempt++
|
||||||
log.Info().Int("attempt", attempt).Msg("planning attempt")
|
log.Info().Int("attempt", attempt).Msg("planning attempt")
|
||||||
if err := dExt.AIAction(text, opts...); err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
|
||||||
"math/rand/v2"
|
"math/rand/v2"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -53,8 +52,8 @@ func convertToAbsolutePoint(driver IDriver, x, y float64) (absX, absY float64, e
|
|||||||
return 0, 0, err
|
return 0, 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
absX = math.Round(float64(windowSize.Width)*x*10) / 10
|
absX = builtin.RoundToOneDecimal(float64(windowSize.Width) * x)
|
||||||
absY = math.Round(float64(windowSize.Height)*y*10) / 10
|
absY = builtin.RoundToOneDecimal(float64(windowSize.Height) * y)
|
||||||
return absX, absY, nil
|
return absX, absY, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
builtinJSON "encoding/json"
|
builtinJSON "encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -667,10 +666,10 @@ func (wd *WDADriver) Drag(fromX, fromY, toX, toY float64, opts ...option.ActionO
|
|||||||
defer postHandler(wd, option.ACTION_Drag, actionOptions)
|
defer postHandler(wd, option.ACTION_Drag, actionOptions)
|
||||||
|
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"fromX": math.Round(fromX*10) / 10,
|
"fromX": builtin.RoundToOneDecimal(fromX),
|
||||||
"fromY": math.Round(fromY*10) / 10,
|
"fromY": builtin.RoundToOneDecimal(fromY),
|
||||||
"toX": math.Round(toX*10) / 10,
|
"toX": builtin.RoundToOneDecimal(toX),
|
||||||
"toY": math.Round(toY*10) / 10,
|
"toY": builtin.RoundToOneDecimal(toY),
|
||||||
}
|
}
|
||||||
option.MergeOptions(data, opts...)
|
option.MergeOptions(data, opts...)
|
||||||
// wda 43 version
|
// wda 43 version
|
||||||
|
|||||||
Reference in New Issue
Block a user