mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 03:30:01 +08:00
feat: check WDA server status before create session
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0+2412101121
|
v5.0.0+2412102150
|
||||||
|
|||||||
@@ -430,7 +430,6 @@ func (dev *IOSDevice) NewDriver(options ...DriverOption) (driverExt *DriverExt,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to init Stub driver")
|
return nil, errors.Wrap(err, "failed to init Stub driver")
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
driver, err = dev.NewHTTPDriver(capabilities)
|
driver, err = dev.NewHTTPDriver(capabilities)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -774,6 +773,20 @@ func (dev *IOSDevice) NewHTTPDriver(capabilities Capabilities) (driver IWebDrive
|
|||||||
if wd.urlPrefix, err = url.Parse(fmt.Sprintf("http://%s:%d", host, localPort)); err != nil {
|
if wd.urlPrefix, err = url.Parse(fmt.Sprintf("http://%s:%d", host, localPort)); err != nil {
|
||||||
return nil, errors.Wrap(code.DeviceHTTPDriverError, err.Error())
|
return nil, errors.Wrap(code.DeviceHTTPDriverError, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check WDA server status
|
||||||
|
status, err := wd.Status()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(code.DeviceHTTPDriverError,
|
||||||
|
"get WDA server status failed: %s", err.Error())
|
||||||
|
}
|
||||||
|
log.Info().Interface("status", status).Msg("get WDA server status")
|
||||||
|
if status.State != "success" {
|
||||||
|
return nil, errors.Wrap(code.DeviceHTTPDriverError,
|
||||||
|
"WDA server status is not success")
|
||||||
|
}
|
||||||
|
|
||||||
|
// create new session
|
||||||
var sessionInfo SessionInfo
|
var sessionInfo SessionInfo
|
||||||
if sessionInfo, err = wd.NewSession(capabilities); err != nil {
|
if sessionInfo, err = wd.NewSession(capabilities); err != nil {
|
||||||
return nil, errors.Wrap(code.DeviceHTTPDriverError, err.Error())
|
return nil, errors.Wrap(code.DeviceHTTPDriverError, err.Error())
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
builtinJSON "encoding/json"
|
builtinJSON "encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"math"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -559,10 +560,10 @@ func (wd *wdaDriver) Drag(fromX, fromY, toX, toY float64, options ...ActionOptio
|
|||||||
toY += actionOptions.getRandomOffset()
|
toY += actionOptions.getRandomOffset()
|
||||||
|
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"fromX": fromX,
|
"fromX": math.Round(fromX*10) / 10,
|
||||||
"fromY": fromY,
|
"fromY": math.Round(fromY*10) / 10,
|
||||||
"toX": toX,
|
"toX": math.Round(toX*10) / 10,
|
||||||
"toY": toY,
|
"toY": math.Round(toY*10) / 10,
|
||||||
}
|
}
|
||||||
if actionOptions.PressDuration > 0 {
|
if actionOptions.PressDuration > 0 {
|
||||||
data["pressDuration"] = actionOptions.PressDuration
|
data["pressDuration"] = actionOptions.PressDuration
|
||||||
|
|||||||
Reference in New Issue
Block a user