mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-06 16:07:45 +08:00
merge master
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0-beta-2506261348
|
v5.0.0-beta-2506261457
|
||||||
|
|||||||
@@ -56,9 +56,11 @@ func (ud *UIA2Driver) Setup() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
ud.Session.SetBaseURL(
|
|
||||||
fmt.Sprintf("http://forward-to-%d:%d/wd/hub",
|
// Store base URL for building full URLs
|
||||||
localPort, ud.Device.Options.UIA2Port))
|
baseURL := fmt.Sprintf("http://forward-to-%d:%d/wd/hub",
|
||||||
|
localPort, ud.Device.Options.UIA2Port)
|
||||||
|
ud.Session.SetBaseURL(baseURL)
|
||||||
|
|
||||||
// uiautomator2 server must be started before
|
// uiautomator2 server must be started before
|
||||||
|
|
||||||
|
|||||||
+10
-25
@@ -10,7 +10,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -103,7 +102,7 @@ func (s *DriverSession) History() []*DriverRequests {
|
|||||||
return s.requests
|
return s.requests
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DriverSession) concatURL(urlStr string) (string, error) {
|
func (s *DriverSession) buildURL(urlStr string) (string, error) {
|
||||||
if urlStr == "" || urlStr == "/" {
|
if urlStr == "" || urlStr == "/" {
|
||||||
if s.baseUrl == "" {
|
if s.baseUrl == "" {
|
||||||
return "", fmt.Errorf("base URL is empty")
|
return "", fmt.Errorf("base URL is empty")
|
||||||
@@ -111,15 +110,7 @@ func (s *DriverSession) concatURL(urlStr string) (string, error) {
|
|||||||
return s.baseUrl, nil
|
return s.baseUrl, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// replace with session ID
|
// Handle full URLs
|
||||||
if s.ID != "" && !strings.Contains(urlStr, s.ID) {
|
|
||||||
sessionPattern := regexp.MustCompile(`/session/([^/]+)/`)
|
|
||||||
if matches := sessionPattern.FindStringSubmatch(urlStr); len(matches) != 0 {
|
|
||||||
urlStr = strings.Replace(urlStr, matches[1], s.ID, 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理完整 URL
|
|
||||||
if strings.HasPrefix(urlStr, "http://") || strings.HasPrefix(urlStr, "https://") {
|
if strings.HasPrefix(urlStr, "http://") || strings.HasPrefix(urlStr, "https://") {
|
||||||
u, err := url.Parse(urlStr)
|
u, err := url.Parse(urlStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -128,27 +119,22 @@ func (s *DriverSession) concatURL(urlStr string) (string, error) {
|
|||||||
return u.String(), nil
|
return u.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理相对路径
|
// handle relative path using ResolveReference
|
||||||
if s.baseUrl == "" {
|
if s.baseUrl == "" {
|
||||||
return "", fmt.Errorf("base URL is empty")
|
return "", fmt.Errorf("base URL is empty")
|
||||||
}
|
}
|
||||||
u, err := url.Parse(s.baseUrl)
|
baseURL, err := url.Parse(s.baseUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to parse base URL: %w", err)
|
return "", fmt.Errorf("failed to parse base URL: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理路径和查询参数
|
relativeURL, err := url.Parse(urlStr)
|
||||||
parts := strings.SplitN(urlStr, "?", 2)
|
|
||||||
u.Path = path.Join(u.Path, parts[0])
|
|
||||||
if len(parts) > 1 {
|
|
||||||
query, err := url.ParseQuery(parts[1])
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to parse query params: %w", err)
|
return "", fmt.Errorf("failed to parse relative URL: %w", err)
|
||||||
}
|
|
||||||
u.RawQuery = query.Encode()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return u.String(), nil
|
finalURL := baseURL.ResolveReference(relativeURL)
|
||||||
|
return finalURL.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DriverSession) GET(urlStr string) (rawResp DriverRawResponse, err error) {
|
func (s *DriverSession) GET(urlStr string) (rawResp DriverRawResponse, err error) {
|
||||||
@@ -194,9 +180,8 @@ func (s *DriverSession) RequestWithRetry(method string, urlStr string, rawBody [
|
|||||||
|
|
||||||
func (s *DriverSession) Request(method string, urlStr string, rawBody []byte) (
|
func (s *DriverSession) Request(method string, urlStr string, rawBody []byte) (
|
||||||
rawResp DriverRawResponse, err error) {
|
rawResp DriverRawResponse, err error) {
|
||||||
|
// build final URL
|
||||||
// concat url with base url
|
rawURL, err := s.buildURL(urlStr)
|
||||||
rawURL, err := s.concatURL(urlStr)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
+70
-56
@@ -6,105 +6,104 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDriverSession_concatURL(t *testing.T) {
|
func TestDriverSession_buildURL(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
baseUrl string
|
baseURL string
|
||||||
urlStr string
|
urlStr string
|
||||||
want string
|
want string
|
||||||
wantErr bool
|
wantErr bool
|
||||||
errMsg string
|
errMsg string
|
||||||
}{
|
}{
|
||||||
|
// Error cases
|
||||||
{
|
{
|
||||||
name: "empty url with empty base url",
|
name: "empty url without baseUrl",
|
||||||
baseUrl: "",
|
|
||||||
urlStr: "",
|
urlStr: "",
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
errMsg: "base URL is empty",
|
errMsg: "base URL is empty",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "empty url with valid base url",
|
name: "relative path without baseUrl",
|
||||||
baseUrl: "http://localhost:8080",
|
urlStr: "/api/users",
|
||||||
urlStr: "",
|
|
||||||
want: "http://localhost:8080",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "root path with empty base url",
|
|
||||||
baseUrl: "",
|
|
||||||
urlStr: "/",
|
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
errMsg: "base URL is empty",
|
errMsg: "base URL is empty",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "root path with valid base url",
|
name: "invalid absolute url",
|
||||||
baseUrl: "http://localhost:8080",
|
urlStr: "http://[invalid-url",
|
||||||
urlStr: "/",
|
wantErr: true,
|
||||||
want: "http://localhost:8080",
|
errMsg: "failed to parse URL",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Absolute URLs (no baseURL needed)
|
||||||
{
|
{
|
||||||
name: "absolute http url",
|
name: "absolute http url",
|
||||||
baseUrl: "http://localhost:8080",
|
|
||||||
urlStr: "http://example.com/api",
|
urlStr: "http://example.com/api",
|
||||||
want: "http://example.com/api",
|
want: "http://example.com/api",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "absolute https url",
|
name: "absolute https url",
|
||||||
baseUrl: "http://localhost:8080",
|
|
||||||
urlStr: "https://example.com/api",
|
urlStr: "https://example.com/api",
|
||||||
want: "https://example.com/api",
|
want: "https://example.com/api",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Empty/root path with baseURL
|
||||||
{
|
{
|
||||||
name: "invalid absolute url",
|
name: "empty url with baseUrl",
|
||||||
baseUrl: "http://localhost:8080",
|
baseURL: "http://localhost:8080",
|
||||||
urlStr: "http://[invalid-url",
|
urlStr: "",
|
||||||
wantErr: true,
|
want: "http://localhost:8080",
|
||||||
errMsg: "failed to parse URL",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "relative path with empty base url",
|
name: "root path with baseUrl",
|
||||||
baseUrl: "",
|
baseURL: "http://localhost:8080",
|
||||||
urlStr: "api/users",
|
urlStr: "/",
|
||||||
wantErr: true,
|
want: "http://localhost:8080",
|
||||||
errMsg: "base URL is empty",
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Relative paths with baseURL
|
||||||
{
|
{
|
||||||
name: "relative path with invalid base url",
|
name: "relative path with leading slash",
|
||||||
baseUrl: "http://[invalid-url",
|
baseURL: "http://localhost:8080",
|
||||||
urlStr: "api/users",
|
urlStr: "/api/users",
|
||||||
wantErr: true,
|
|
||||||
errMsg: "failed to parse base URL",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "relative path with valid base url",
|
|
||||||
baseUrl: "http://localhost:8080",
|
|
||||||
urlStr: "api/users",
|
|
||||||
want: "http://localhost:8080/api/users",
|
want: "http://localhost:8080/api/users",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "relative path without leading slash",
|
||||||
|
baseURL: "http://localhost:8080/api",
|
||||||
|
urlStr: "users",
|
||||||
|
want: "http://localhost:8080/users",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "relative path with query params",
|
name: "relative path with query params",
|
||||||
baseUrl: "http://localhost:8080",
|
baseURL: "http://localhost:8080",
|
||||||
urlStr: "api/users?id=1&name=test",
|
urlStr: "/api/users?id=1&name=test",
|
||||||
want: "http://localhost:8080/api/users?id=1&name=test",
|
want: "http://localhost:8080/api/users?id=1&name=test",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// BaseURL with path scenarios
|
||||||
{
|
{
|
||||||
name: "base url with query params",
|
name: "baseUrl with path + relative path",
|
||||||
baseUrl: "http://localhost:8080?token=123",
|
baseURL: "http://localhost:8080/api/v1",
|
||||||
urlStr: "api/users?id=1",
|
urlStr: "users",
|
||||||
want: "http://localhost:8080/api/users?id=1",
|
want: "http://localhost:8080/api/users",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "invalid query params",
|
name: "baseUrl with trailing slash + relative path",
|
||||||
baseUrl: "http://localhost:8080",
|
baseURL: "http://localhost:8080/api/",
|
||||||
urlStr: "api/users?id=%invalid",
|
urlStr: "users",
|
||||||
wantErr: true,
|
want: "http://localhost:8080/api/users",
|
||||||
errMsg: "failed to parse query params",
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
s := &DriverSession{baseUrl: tt.baseUrl}
|
s := NewDriverSession()
|
||||||
got, err := s.concatURL(tt.urlStr)
|
if tt.baseURL != "" {
|
||||||
|
s.SetBaseURL(tt.baseURL)
|
||||||
|
}
|
||||||
|
|
||||||
|
got, err := s.buildURL(tt.urlStr)
|
||||||
|
|
||||||
if tt.wantErr {
|
if tt.wantErr {
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
@@ -121,22 +120,37 @@ func TestDriverSession_concatURL(t *testing.T) {
|
|||||||
func TestDriverSession(t *testing.T) {
|
func TestDriverSession(t *testing.T) {
|
||||||
session := NewDriverSession()
|
session := NewDriverSession()
|
||||||
session.SetBaseURL("https://postman-echo.com")
|
session.SetBaseURL("https://postman-echo.com")
|
||||||
resp, err := session.GET("/get")
|
|
||||||
|
// Test GET with full URL
|
||||||
|
resp, err := session.GET("https://postman-echo.com/get")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
t.Log(resp)
|
t.Log(resp)
|
||||||
|
|
||||||
resp, err = session.GET("/get?a=1&b=2")
|
// Test GET with full URL and query params
|
||||||
|
resp, err = session.GET("https://postman-echo.com/get?a=1&b=2")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
t.Log(resp)
|
t.Log(resp)
|
||||||
|
|
||||||
|
// Test GET with relative path (using baseURL)
|
||||||
|
resp, err = session.GET("/get")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
t.Log(resp)
|
||||||
|
|
||||||
|
// Verify request history
|
||||||
driverRequests := session.History()
|
driverRequests := session.History()
|
||||||
assert.Equal(t, 2, len(driverRequests))
|
assert.Equal(t, 3, len(driverRequests))
|
||||||
|
|
||||||
|
// Test reset functionality
|
||||||
session.Reset()
|
session.Reset()
|
||||||
driverRequests = session.History()
|
driverRequests = session.History()
|
||||||
assert.Equal(t, 0, len(driverRequests))
|
assert.Equal(t, 0, len(driverRequests))
|
||||||
|
|
||||||
resp, err = session.GET("https://postman-echo.com/get")
|
// Test POST with relative path
|
||||||
|
resp, err = session.POST(nil, "/post")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
t.Log(resp)
|
t.Log(resp)
|
||||||
|
|
||||||
|
// Verify one request was made after reset
|
||||||
|
driverRequests = session.History()
|
||||||
|
assert.Equal(t, 1, len(driverRequests))
|
||||||
}
|
}
|
||||||
|
|||||||
+42
-106
@@ -137,7 +137,10 @@ func (wd *WDADriver) Setup() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
wd.Session.SetBaseURL(fmt.Sprintf("http://localhost:%d", localPort))
|
|
||||||
|
// Store base URL for building full URLs
|
||||||
|
baseURL := fmt.Sprintf("http://localhost:%d", localPort)
|
||||||
|
wd.Session.SetBaseURL(baseURL)
|
||||||
|
|
||||||
if err = wd.initMjpegClient(); err != nil {
|
if err = wd.initMjpegClient(); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -167,16 +170,7 @@ func (wd *WDADriver) InitSession(capabilities option.Capabilities) error {
|
|||||||
} else {
|
} else {
|
||||||
data["capabilities"] = map[string]interface{}{"alwaysMatch": capabilities}
|
data["capabilities"] = map[string]interface{}{"alwaysMatch": capabilities}
|
||||||
}
|
}
|
||||||
rawResp, err := wd.Session.POST(data, "/session")
|
// No longer need to track session ID
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
reply := new(struct{ Value struct{ SessionId string } })
|
|
||||||
if err = json.Unmarshal(rawResp, reply); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// update session ID
|
|
||||||
wd.Session.ID = reply.Value.SessionId
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,10 +179,6 @@ func (wd *WDADriver) DeleteSession() (err error) {
|
|||||||
wd.mjpegClient.CloseIdleConnections()
|
wd.mjpegClient.CloseIdleConnections()
|
||||||
}
|
}
|
||||||
|
|
||||||
// [[FBRoute DELETE:@""] respondWithTarget:self action:@selector(handleDeleteSession:)]
|
|
||||||
urlStr := fmt.Sprintf("/session/%s", wd.Session.ID)
|
|
||||||
_, err = wd.Session.DELETE(urlStr)
|
|
||||||
wd.Session.ID = ""
|
|
||||||
wd.Session.client.CloseIdleConnections()
|
wd.Session.client.CloseIdleConnections()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -216,8 +206,7 @@ func (wd *WDADriver) DeviceInfo() (deviceInfo types.DeviceInfo, err error) {
|
|||||||
// [[FBRoute GET:@"/wda/device/info"] respondWithTarget:self action:@selector(handleGetDeviceInfo:)]
|
// [[FBRoute GET:@"/wda/device/info"] respondWithTarget:self action:@selector(handleGetDeviceInfo:)]
|
||||||
// [[FBRoute GET:@"/wda/device/info"].withoutSession
|
// [[FBRoute GET:@"/wda/device/info"].withoutSession
|
||||||
var rawResp DriverRawResponse
|
var rawResp DriverRawResponse
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/device/info", wd.Session.ID)
|
if rawResp, err = wd.Session.GET("/wda/device/info"); err != nil {
|
||||||
if rawResp, err = wd.Session.GET(urlStr); err != nil {
|
|
||||||
return types.DeviceInfo{}, err
|
return types.DeviceInfo{}, err
|
||||||
}
|
}
|
||||||
reply := new(struct{ Value struct{ types.DeviceInfo } })
|
reply := new(struct{ Value struct{ types.DeviceInfo } })
|
||||||
@@ -232,8 +221,7 @@ func (wd *WDADriver) Location() (location types.Location, err error) {
|
|||||||
// [[FBRoute GET:@"/wda/device/location"] respondWithTarget:self action:@selector(handleGetLocation:)]
|
// [[FBRoute GET:@"/wda/device/location"] respondWithTarget:self action:@selector(handleGetLocation:)]
|
||||||
// [[FBRoute GET:@"/wda/device/location"].withoutSession
|
// [[FBRoute GET:@"/wda/device/location"].withoutSession
|
||||||
var rawResp DriverRawResponse
|
var rawResp DriverRawResponse
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/device/location", wd.Session.ID)
|
if rawResp, err = wd.Session.GET("/wda/device/location"); err != nil {
|
||||||
if rawResp, err = wd.Session.GET(urlStr); err != nil {
|
|
||||||
return types.Location{}, err
|
return types.Location{}, err
|
||||||
}
|
}
|
||||||
reply := new(struct{ Value struct{ types.Location } })
|
reply := new(struct{ Value struct{ types.Location } })
|
||||||
@@ -247,8 +235,7 @@ func (wd *WDADriver) Location() (location types.Location, err error) {
|
|||||||
func (wd *WDADriver) BatteryInfo() (batteryInfo types.BatteryInfo, err error) {
|
func (wd *WDADriver) BatteryInfo() (batteryInfo types.BatteryInfo, err error) {
|
||||||
// [[FBRoute GET:@"/wda/batteryInfo"] respondWithTarget:self action:@selector(handleGetBatteryInfo:)]
|
// [[FBRoute GET:@"/wda/batteryInfo"] respondWithTarget:self action:@selector(handleGetBatteryInfo:)]
|
||||||
var rawResp DriverRawResponse
|
var rawResp DriverRawResponse
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/batteryInfo", wd.Session.ID)
|
if rawResp, err = wd.Session.GET("/wda/batteryInfo"); err != nil {
|
||||||
if rawResp, err = wd.Session.GET(urlStr); err != nil {
|
|
||||||
return types.BatteryInfo{}, err
|
return types.BatteryInfo{}, err
|
||||||
}
|
}
|
||||||
reply := new(struct{ Value struct{ types.BatteryInfo } })
|
reply := new(struct{ Value struct{ types.BatteryInfo } })
|
||||||
@@ -267,8 +254,7 @@ func (wd *WDADriver) WindowSize() (size types.Size, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var rawResp DriverRawResponse
|
var rawResp DriverRawResponse
|
||||||
urlStr := fmt.Sprintf("/session/%s/window/size", wd.Session.ID)
|
if rawResp, err = wd.Session.GET("/wings/window/size"); err != nil {
|
||||||
if rawResp, err = wd.Session.GET(urlStr); err != nil {
|
|
||||||
return types.Size{}, errors.Wrap(err, "get window size failed by WDA request")
|
return types.Size{}, errors.Wrap(err, "get window size failed by WDA request")
|
||||||
}
|
}
|
||||||
reply := new(struct{ Value struct{ types.Size } })
|
reply := new(struct{ Value struct{ types.Size } })
|
||||||
@@ -307,8 +293,7 @@ type Screen struct {
|
|||||||
func (wd *WDADriver) Screen() (screen Screen, err error) {
|
func (wd *WDADriver) Screen() (screen Screen, err error) {
|
||||||
// [[FBRoute GET:@"/wda/screen"] respondWithTarget:self action:@selector(handleGetScreen:)]
|
// [[FBRoute GET:@"/wda/screen"] respondWithTarget:self action:@selector(handleGetScreen:)]
|
||||||
var rawResp DriverRawResponse
|
var rawResp DriverRawResponse
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/screen", wd.Session.ID)
|
if rawResp, err = wd.Session.GET("/wda/screen"); err != nil {
|
||||||
if rawResp, err = wd.Session.GET(urlStr); err != nil {
|
|
||||||
return Screen{}, err
|
return Screen{}, err
|
||||||
}
|
}
|
||||||
reply := new(struct{ Value struct{ Screen } })
|
reply := new(struct{ Value struct{ Screen } })
|
||||||
@@ -322,8 +307,7 @@ func (wd *WDADriver) Screen() (screen Screen, err error) {
|
|||||||
func (wd *WDADriver) ScreenShot(opts ...option.ActionOption) (raw *bytes.Buffer, err error) {
|
func (wd *WDADriver) ScreenShot(opts ...option.ActionOption) (raw *bytes.Buffer, err error) {
|
||||||
// [[FBRoute GET:@"/screenshot"] respondWithTarget:self action:@selector(handleGetScreenshot:)]
|
// [[FBRoute GET:@"/screenshot"] respondWithTarget:self action:@selector(handleGetScreenshot:)]
|
||||||
// [[FBRoute GET:@"/screenshot"].withoutSession respondWithTarget:self action:@selector(handleGetScreenshot:)]
|
// [[FBRoute GET:@"/screenshot"].withoutSession respondWithTarget:self action:@selector(handleGetScreenshot:)]
|
||||||
urlStr := fmt.Sprintf("/session/%s/screenshot", wd.Session.ID)
|
rawResp, err := wd.Session.GET("/screenshot")
|
||||||
rawResp, err := wd.Session.GET(urlStr)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(code.DeviceScreenShotError,
|
return nil, errors.Wrap(code.DeviceScreenShotError,
|
||||||
fmt.Sprintf("WDA screenshot failed %v", err))
|
fmt.Sprintf("WDA screenshot failed %v", err))
|
||||||
@@ -351,8 +335,7 @@ func (wd *WDADriver) ActiveAppInfo() (info types.AppInfo, err error) {
|
|||||||
// [[FBRoute GET:@"/wda/activeAppInfo"] respondWithTarget:self action:@selector(handleActiveAppInfo:)]
|
// [[FBRoute GET:@"/wda/activeAppInfo"] respondWithTarget:self action:@selector(handleActiveAppInfo:)]
|
||||||
// [[FBRoute GET:@"/wda/activeAppInfo"].withoutSession
|
// [[FBRoute GET:@"/wda/activeAppInfo"].withoutSession
|
||||||
var rawResp DriverRawResponse
|
var rawResp DriverRawResponse
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/activeAppInfo", wd.Session.ID)
|
if rawResp, err = wd.Session.GET("/wda/activeAppInfo"); err != nil {
|
||||||
if rawResp, err = wd.Session.GET(urlStr); err != nil {
|
|
||||||
return types.AppInfo{}, err
|
return types.AppInfo{}, err
|
||||||
}
|
}
|
||||||
reply := new(struct{ Value struct{ types.AppInfo } })
|
reply := new(struct{ Value struct{ types.AppInfo } })
|
||||||
@@ -366,8 +349,7 @@ func (wd *WDADriver) ActiveAppInfo() (info types.AppInfo, err error) {
|
|||||||
func (wd *WDADriver) ActiveAppsList() (appsList []types.AppBaseInfo, err error) {
|
func (wd *WDADriver) ActiveAppsList() (appsList []types.AppBaseInfo, err error) {
|
||||||
// [[FBRoute GET:@"/wda/apps/list"] respondWithTarget:self action:@selector(handleGetActiveAppsList:)]
|
// [[FBRoute GET:@"/wda/apps/list"] respondWithTarget:self action:@selector(handleGetActiveAppsList:)]
|
||||||
var rawResp DriverRawResponse
|
var rawResp DriverRawResponse
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/apps/list", wd.Session.ID)
|
if rawResp, err = wd.Session.GET("/wda/apps/list"); err != nil {
|
||||||
if rawResp, err = wd.Session.GET(urlStr); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
reply := new(struct{ Value []types.AppBaseInfo })
|
reply := new(struct{ Value []types.AppBaseInfo })
|
||||||
@@ -379,28 +361,15 @@ func (wd *WDADriver) ActiveAppsList() (appsList []types.AppBaseInfo, err error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (wd *WDADriver) AppState(bundleId string) (runState types.AppState, err error) {
|
func (wd *WDADriver) AppState(bundleId string) (runState types.AppState, err error) {
|
||||||
// [[FBRoute POST:@"/wda/apps/state"] respondWithTarget:self action:@selector(handleSessionAppState:)]
|
log.Warn().Str("bundleId", bundleId).Msg("WDADriver.AppState not implemented")
|
||||||
data := map[string]interface{}{"bundleId": bundleId}
|
return 0, nil
|
||||||
var rawResp DriverRawResponse
|
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/apps/state", wd.Session.ID)
|
|
||||||
if rawResp, err = wd.Session.POST(data, urlStr); err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
reply := new(struct{ Value types.AppState })
|
|
||||||
if err = json.Unmarshal(rawResp, reply); err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
runState = reply.Value
|
|
||||||
_ = rawResp
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wd *WDADriver) IsLocked() (locked bool, err error) {
|
func (wd *WDADriver) IsLocked() (locked bool, err error) {
|
||||||
// [[FBRoute GET:@"/wda/locked"] respondWithTarget:self action:@selector(handleIsLocked:)]
|
// [[FBRoute GET:@"/wda/locked"] respondWithTarget:self action:@selector(handleIsLocked:)]
|
||||||
// [[FBRoute GET:@"/wda/locked"].withoutSession
|
// [[FBRoute GET:@"/wda/locked"].withoutSession
|
||||||
var rawResp DriverRawResponse
|
var rawResp DriverRawResponse
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/locked", wd.Session.ID)
|
if rawResp, err = wd.Session.GET("/wda/locked"); err != nil {
|
||||||
if rawResp, err = wd.Session.GET(urlStr); err != nil {
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
if locked, err = rawResp.ValueConvertToBool(); err != nil {
|
if locked, err = rawResp.ValueConvertToBool(); err != nil {
|
||||||
@@ -412,16 +381,14 @@ func (wd *WDADriver) IsLocked() (locked bool, err error) {
|
|||||||
func (wd *WDADriver) Unlock() (err error) {
|
func (wd *WDADriver) Unlock() (err error) {
|
||||||
// [[FBRoute POST:@"/wda/unlock"] respondWithTarget:self action:@selector(handleUnlock:)]
|
// [[FBRoute POST:@"/wda/unlock"] respondWithTarget:self action:@selector(handleUnlock:)]
|
||||||
// [[FBRoute POST:@"/wda/unlock"].withoutSession
|
// [[FBRoute POST:@"/wda/unlock"].withoutSession
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/unlock", wd.Session.ID)
|
_, err = wd.Session.POST(nil, "/wda/unlock")
|
||||||
_, err = wd.Session.POST(nil, urlStr)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wd *WDADriver) Lock() (err error) {
|
func (wd *WDADriver) Lock() (err error) {
|
||||||
// [[FBRoute POST:@"/wda/lock"] respondWithTarget:self action:@selector(handleLock:)]
|
// [[FBRoute POST:@"/wda/lock"] respondWithTarget:self action:@selector(handleLock:)]
|
||||||
// [[FBRoute POST:@"/wda/lock"].withoutSession
|
// [[FBRoute POST:@"/wda/lock"].withoutSession
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/lock", wd.Session.ID)
|
_, err = wd.Session.POST(nil, "/wda/lock")
|
||||||
_, err = wd.Session.POST(nil, urlStr)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,8 +402,7 @@ func (wd *WDADriver) AlertText() (text string, err error) {
|
|||||||
// [[FBRoute GET:@"/alert/text"] respondWithTarget:self action:@selector(handleAlertGetTextCommand:)]
|
// [[FBRoute GET:@"/alert/text"] respondWithTarget:self action:@selector(handleAlertGetTextCommand:)]
|
||||||
// [[FBRoute GET:@"/alert/text"].withoutSession
|
// [[FBRoute GET:@"/alert/text"].withoutSession
|
||||||
var rawResp DriverRawResponse
|
var rawResp DriverRawResponse
|
||||||
urlStr := fmt.Sprintf("/session/%s/alert/text", wd.Session.ID)
|
if rawResp, err = wd.Session.GET("/alert/text"); err != nil {
|
||||||
if rawResp, err = wd.Session.GET(urlStr); err != nil {
|
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if text, err = rawResp.ValueConvertToString(); err != nil {
|
if text, err = rawResp.ValueConvertToString(); err != nil {
|
||||||
@@ -448,8 +414,7 @@ func (wd *WDADriver) AlertText() (text string, err error) {
|
|||||||
func (wd *WDADriver) AlertButtons() (btnLabels []string, err error) {
|
func (wd *WDADriver) AlertButtons() (btnLabels []string, err error) {
|
||||||
// [[FBRoute GET:@"/wda/alert/buttons"] respondWithTarget:self action:@selector(handleGetAlertButtonsCommand:)]
|
// [[FBRoute GET:@"/wda/alert/buttons"] respondWithTarget:self action:@selector(handleGetAlertButtonsCommand:)]
|
||||||
var rawResp DriverRawResponse
|
var rawResp DriverRawResponse
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/alert/buttons", wd.Session.ID)
|
if rawResp, err = wd.Session.GET("/wda/alert/buttons"); err != nil {
|
||||||
if rawResp, err = wd.Session.GET(urlStr); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
reply := new(struct{ Value []string })
|
reply := new(struct{ Value []string })
|
||||||
@@ -485,8 +450,7 @@ func (wd *WDADriver) AlertDismiss(label ...string) (err error) {
|
|||||||
func (wd *WDADriver) AlertSendKeys(text string) (err error) {
|
func (wd *WDADriver) AlertSendKeys(text string) (err error) {
|
||||||
// [[FBRoute POST:@"/alert/text"] respondWithTarget:self action:@selector(handleAlertSetTextCommand:)]
|
// [[FBRoute POST:@"/alert/text"] respondWithTarget:self action:@selector(handleAlertSetTextCommand:)]
|
||||||
data := map[string]interface{}{"value": strings.Split(text, "")}
|
data := map[string]interface{}{"value": strings.Split(text, "")}
|
||||||
urlStr := fmt.Sprintf("/session/%s/alert/text", wd.Session.ID)
|
_, err = wd.Session.POST(data, "/alert/text")
|
||||||
_, err = wd.Session.POST(data, urlStr)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,8 +462,7 @@ func (wd *WDADriver) AppLaunch(bundleId string) (err error) {
|
|||||||
data["environment"] = map[string]interface{}{
|
data["environment"] = map[string]interface{}{
|
||||||
"SHOW_EXPLORER": "NO",
|
"SHOW_EXPLORER": "NO",
|
||||||
}
|
}
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/apps/launch", wd.Session.ID)
|
_, err = wd.Session.POST(data, "/wings/apps/launch")
|
||||||
_, err = wd.Session.POST(data, urlStr)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(code.MobileUILaunchAppError,
|
return errors.Wrap(code.MobileUILaunchAppError,
|
||||||
fmt.Sprintf("wda launch failed: %v", err))
|
fmt.Sprintf("wda launch failed: %v", err))
|
||||||
@@ -524,8 +487,7 @@ func (wd *WDADriver) AppTerminate(bundleId string) (successful bool, err error)
|
|||||||
// [[FBRoute POST:@"/wda/apps/terminate"] respondWithTarget:self action:@selector(handleSessionAppTerminate:)]
|
// [[FBRoute POST:@"/wda/apps/terminate"] respondWithTarget:self action:@selector(handleSessionAppTerminate:)]
|
||||||
data := map[string]interface{}{"bundleId": bundleId}
|
data := map[string]interface{}{"bundleId": bundleId}
|
||||||
var rawResp DriverRawResponse
|
var rawResp DriverRawResponse
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/apps/terminate", wd.Session.ID)
|
if rawResp, err = wd.Session.POST(data, "/wings/apps/terminate"); err != nil {
|
||||||
if rawResp, err = wd.Session.POST(data, urlStr); err != nil {
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
if successful, err = rawResp.ValueConvertToBool(); err != nil {
|
if successful, err = rawResp.ValueConvertToBool(); err != nil {
|
||||||
@@ -538,21 +500,13 @@ func (wd *WDADriver) AppActivate(bundleId string) (err error) {
|
|||||||
log.Info().Str("bundleId", bundleId).Msg("WDADriver.AppActivate")
|
log.Info().Str("bundleId", bundleId).Msg("WDADriver.AppActivate")
|
||||||
// [[FBRoute POST:@"/wda/apps/activate"] respondWithTarget:self action:@selector(handleSessionAppActivate:)]
|
// [[FBRoute POST:@"/wda/apps/activate"] respondWithTarget:self action:@selector(handleSessionAppActivate:)]
|
||||||
data := map[string]interface{}{"bundleId": bundleId}
|
data := map[string]interface{}{"bundleId": bundleId}
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/apps/activate", wd.Session.ID)
|
_, err = wd.Session.POST(data, "/wings/apps/activate")
|
||||||
_, err = wd.Session.POST(data, urlStr)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wd *WDADriver) AppDeactivate(second float64) (err error) {
|
func (wd *WDADriver) AppDeactivate(second float64) (err error) {
|
||||||
log.Info().Float64("second", second).Msg("WDADriver.AppDeactivate")
|
log.Warn().Float64("second", second).Msg("WDADriver.AppDeactivate not implemented")
|
||||||
// [[FBRoute POST:@"/wda/deactivateApp"] respondWithTarget:self action:@selector(handleDeactivateAppCommand:)]
|
return nil
|
||||||
if second < 3 {
|
|
||||||
second = 3.0
|
|
||||||
}
|
|
||||||
data := map[string]interface{}{"duration": second}
|
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/deactivateApp", wd.Session.ID)
|
|
||||||
_, err = wd.Session.POST(data, urlStr)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wd *WDADriver) ForegroundInfo() (appInfo types.AppInfo, err error) {
|
func (wd *WDADriver) ForegroundInfo() (appInfo types.AppInfo, err error) {
|
||||||
@@ -609,8 +563,7 @@ func (wd *WDADriver) TapAbsXY(x, y float64, opts ...option.ActionOption) error {
|
|||||||
}
|
}
|
||||||
option.MergeOptions(data, opts...)
|
option.MergeOptions(data, opts...)
|
||||||
|
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/tap/0", wd.Session.ID)
|
_, err = wd.Session.POST(data, "/wings/interaction/tap")
|
||||||
_, err = wd.Session.POST(data, urlStr)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -632,8 +585,7 @@ func (wd *WDADriver) DoubleTap(x, y float64, opts ...option.ActionOption) error
|
|||||||
"x": x,
|
"x": x,
|
||||||
"y": y,
|
"y": y,
|
||||||
}
|
}
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/doubleTap", wd.Session.ID)
|
_, err = wd.Session.POST(data, "/wings/interaction/doubleTap")
|
||||||
_, err = wd.Session.POST(data, urlStr)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -672,10 +624,8 @@ func (wd *WDADriver) Drag(fromX, fromY, toX, toY float64, opts ...option.ActionO
|
|||||||
"toY": builtin.RoundToOneDecimal(toY),
|
"toY": builtin.RoundToOneDecimal(toY),
|
||||||
}
|
}
|
||||||
option.MergeOptions(data, opts...)
|
option.MergeOptions(data, opts...)
|
||||||
// wda 43 version
|
// wda 50 version
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/dragfromtoforduration", wd.Session.ID)
|
_, err = wd.Session.POST(data, "/wings/interaction/drag")
|
||||||
_, err = wd.Session.POST(data, urlStr)
|
|
||||||
// _, err = wd.Session.POST(data, "/session", wd.Session.ID, "/wda/drag")
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -689,8 +639,7 @@ func (wd *WDADriver) SetPasteboard(contentType types.PasteboardType, content str
|
|||||||
"contentType": contentType,
|
"contentType": contentType,
|
||||||
"content": base64.StdEncoding.EncodeToString([]byte(content)),
|
"content": base64.StdEncoding.EncodeToString([]byte(content)),
|
||||||
}
|
}
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/setPasteboard", wd.Session.ID)
|
_, err = wd.Session.POST(data, "/wda/setPasteboard")
|
||||||
_, err = wd.Session.POST(data, urlStr)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -698,8 +647,7 @@ func (wd *WDADriver) GetPasteboard(contentType types.PasteboardType) (raw *bytes
|
|||||||
// [[FBRoute POST:@"/wda/getPasteboard"] respondWithTarget:self action:@selector(handleGetPasteboard:)]
|
// [[FBRoute POST:@"/wda/getPasteboard"] respondWithTarget:self action:@selector(handleGetPasteboard:)]
|
||||||
data := map[string]interface{}{"contentType": contentType}
|
data := map[string]interface{}{"contentType": contentType}
|
||||||
var rawResp DriverRawResponse
|
var rawResp DriverRawResponse
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/getPasteboard", wd.Session.ID)
|
if rawResp, err = wd.Session.POST(data, "/wda/getPasteboard"); err != nil {
|
||||||
if rawResp, err = wd.Session.POST(data, urlStr); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if raw, err = rawResp.ValueDecodeAsBase64(); err != nil {
|
if raw, err = rawResp.ValueDecodeAsBase64(); err != nil {
|
||||||
@@ -717,8 +665,7 @@ func (wd *WDADriver) Input(text string, opts ...option.ActionOption) (err error)
|
|||||||
// [[FBRoute POST:@"/wda/keys"] respondWithTarget:self action:@selector(handleKeys:)]
|
// [[FBRoute POST:@"/wda/keys"] respondWithTarget:self action:@selector(handleKeys:)]
|
||||||
data := map[string]interface{}{"value": strings.Split(text, "")}
|
data := map[string]interface{}{"value": strings.Split(text, "")}
|
||||||
option.MergeOptions(data, opts...)
|
option.MergeOptions(data, opts...)
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/keys", wd.Session.ID)
|
_, err = wd.Session.POST(data, "/gtf/interaction/input")
|
||||||
_, err = wd.Session.POST(data, urlStr)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -751,16 +698,14 @@ func (wd *WDADriver) PressButton(button types.DeviceButton) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
data := map[string]interface{}{"name": button}
|
data := map[string]interface{}{"name": button}
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/pressButton", wd.Session.ID)
|
_, err = wd.Session.POST(data, "/wda/pressButton")
|
||||||
_, err = wd.Session.POST(data, urlStr)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wd *WDADriver) Orientation() (orientation types.Orientation, err error) {
|
func (wd *WDADriver) Orientation() (orientation types.Orientation, err error) {
|
||||||
// [[FBRoute GET:@"/orientation"] respondWithTarget:self action:@selector(handleGetOrientation:)]
|
// [[FBRoute GET:@"/orientation"] respondWithTarget:self action:@selector(handleGetOrientation:)]
|
||||||
var rawResp DriverRawResponse
|
var rawResp DriverRawResponse
|
||||||
urlStr := fmt.Sprintf("/session/%s/orientation", wd.Session.ID)
|
if rawResp, err = wd.Session.GET("/orientation"); err != nil {
|
||||||
if rawResp, err = wd.Session.GET(urlStr); err != nil {
|
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
reply := new(struct{ Value types.Orientation })
|
reply := new(struct{ Value types.Orientation })
|
||||||
@@ -774,16 +719,14 @@ func (wd *WDADriver) Orientation() (orientation types.Orientation, err error) {
|
|||||||
func (wd *WDADriver) SetOrientation(orientation types.Orientation) (err error) {
|
func (wd *WDADriver) SetOrientation(orientation types.Orientation) (err error) {
|
||||||
// [[FBRoute POST:@"/orientation"] respondWithTarget:self action:@selector(handleSetOrientation:)]
|
// [[FBRoute POST:@"/orientation"] respondWithTarget:self action:@selector(handleSetOrientation:)]
|
||||||
data := map[string]interface{}{"orientation": orientation}
|
data := map[string]interface{}{"orientation": orientation}
|
||||||
urlStr := fmt.Sprintf("/session/%s/orientation", wd.Session.ID)
|
_, err = wd.Session.POST(data, "/orientation")
|
||||||
_, err = wd.Session.POST(data, urlStr)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wd *WDADriver) Rotation() (rotation types.Rotation, err error) {
|
func (wd *WDADriver) Rotation() (rotation types.Rotation, err error) {
|
||||||
// [[FBRoute GET:@"/rotation"] respondWithTarget:self action:@selector(handleGetRotation:)]
|
// [[FBRoute GET:@"/rotation"] respondWithTarget:self action:@selector(handleGetRotation:)]
|
||||||
var rawResp DriverRawResponse
|
var rawResp DriverRawResponse
|
||||||
urlStr := fmt.Sprintf("/session/%s/rotation", wd.Session.ID)
|
if rawResp, err = wd.Session.GET("/rotation"); err != nil {
|
||||||
if rawResp, err = wd.Session.GET(urlStr); err != nil {
|
|
||||||
return types.Rotation{}, err
|
return types.Rotation{}, err
|
||||||
}
|
}
|
||||||
reply := new(struct{ Value types.Rotation })
|
reply := new(struct{ Value types.Rotation })
|
||||||
@@ -796,18 +739,14 @@ func (wd *WDADriver) Rotation() (rotation types.Rotation, err error) {
|
|||||||
|
|
||||||
func (wd *WDADriver) SetRotation(rotation types.Rotation) (err error) {
|
func (wd *WDADriver) SetRotation(rotation types.Rotation) (err error) {
|
||||||
// [[FBRoute POST:@"/rotation"] respondWithTarget:self action:@selector(handleSetRotation:)]
|
// [[FBRoute POST:@"/rotation"] respondWithTarget:self action:@selector(handleSetRotation:)]
|
||||||
urlStr := fmt.Sprintf("/session/%s/rotation", wd.Session.ID)
|
_, err = wd.Session.POST(rotation, "/rotation")
|
||||||
_, err = wd.Session.POST(rotation, urlStr)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wd *WDADriver) Source(srcOpt ...option.SourceOption) (source string, err error) {
|
func (wd *WDADriver) Source(srcOpt ...option.SourceOption) (source string, err error) {
|
||||||
// [[FBRoute GET:@"/source"] respondWithTarget:self action:@selector(handleGetSourceCommand:)]
|
// [[FBRoute GET:@"/source"] respondWithTarget:self action:@selector(handleGetSourceCommand:)]
|
||||||
// [[FBRoute GET:@"/source"].withoutSession
|
// [[FBRoute GET:@"/source"].withoutSession
|
||||||
// urlStr, err := wd.Session.concatURL("/session", wd.Session.ID)
|
|
||||||
// if err != nil {
|
|
||||||
// return "", err
|
|
||||||
// }
|
|
||||||
options := option.NewSourceOptions(srcOpt...)
|
options := option.NewSourceOptions(srcOpt...)
|
||||||
query := options.Query()
|
query := options.Query()
|
||||||
if len(query) > 0 {
|
if len(query) > 0 {
|
||||||
@@ -837,8 +776,7 @@ func (wd *WDADriver) AccessibleSource() (source string, err error) {
|
|||||||
// [[FBRoute GET:@"/wda/accessibleSource"] respondWithTarget:self action:@selector(handleGetAccessibleSourceCommand:)]
|
// [[FBRoute GET:@"/wda/accessibleSource"] respondWithTarget:self action:@selector(handleGetAccessibleSourceCommand:)]
|
||||||
// [[FBRoute GET:@"/wda/accessibleSource"].withoutSession
|
// [[FBRoute GET:@"/wda/accessibleSource"].withoutSession
|
||||||
var rawResp DriverRawResponse
|
var rawResp DriverRawResponse
|
||||||
urlStr := fmt.Sprintf("/session/%s/wda/accessibleSource", wd.Session.ID)
|
if rawResp, err = wd.Session.GET("/wda/accessibleSource"); err != nil {
|
||||||
if rawResp, err = wd.Session.GET(urlStr); err != nil {
|
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
var jr builtinJSON.RawMessage
|
var jr builtinJSON.RawMessage
|
||||||
@@ -869,8 +807,7 @@ func (wd *WDADriver) IsHealthy() (healthy bool, err error) {
|
|||||||
func (wd *WDADriver) GetAppiumSettings() (settings map[string]interface{}, err error) {
|
func (wd *WDADriver) GetAppiumSettings() (settings map[string]interface{}, err error) {
|
||||||
// [[FBRoute GET:@"/appium/settings"] respondWithTarget:self action:@selector(handleGetSettings:)]
|
// [[FBRoute GET:@"/appium/settings"] respondWithTarget:self action:@selector(handleGetSettings:)]
|
||||||
var rawResp DriverRawResponse
|
var rawResp DriverRawResponse
|
||||||
urlStr := fmt.Sprintf("/session/%s/appium/settings", wd.Session.ID)
|
if rawResp, err = wd.Session.GET("/appium/settings"); err != nil {
|
||||||
if rawResp, err = wd.Session.GET(urlStr); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
reply := new(struct{ Value map[string]interface{} })
|
reply := new(struct{ Value map[string]interface{} })
|
||||||
@@ -885,8 +822,7 @@ func (wd *WDADriver) SetAppiumSettings(settings map[string]interface{}) (ret map
|
|||||||
// [[FBRoute POST:@"/appium/settings"] respondWithTarget:self action:@selector(handleSetSettings:)]
|
// [[FBRoute POST:@"/appium/settings"] respondWithTarget:self action:@selector(handleSetSettings:)]
|
||||||
data := map[string]interface{}{"settings": settings}
|
data := map[string]interface{}{"settings": settings}
|
||||||
var rawResp DriverRawResponse
|
var rawResp DriverRawResponse
|
||||||
urlStr := fmt.Sprintf("/session/%s/appium/settings", wd.Session.ID)
|
if rawResp, err = wd.Session.POST(data, "/appium/settings"); err != nil {
|
||||||
if rawResp, err = wd.Session.POST(data, urlStr); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
reply := new(struct{ Value map[string]interface{} })
|
reply := new(struct{ Value map[string]interface{} })
|
||||||
|
|||||||
Reference in New Issue
Block a user