mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 15:37:35 +08:00
Merge branch 'wings_interface_merge' into 'master'
Wings interface merge See merge request iesqa/httprunner!156
This commit is contained in:
@@ -69,6 +69,7 @@ var (
|
|||||||
DeviceConnectionError = errors.New("device general connection error") // 50
|
DeviceConnectionError = errors.New("device general connection error") // 50
|
||||||
DeviceHTTPDriverError = errors.New("device HTTP driver error") // 51
|
DeviceHTTPDriverError = errors.New("device HTTP driver error") // 51
|
||||||
DeviceUSBDriverError = errors.New("device USB driver error") // 52
|
DeviceUSBDriverError = errors.New("device USB driver error") // 52
|
||||||
|
DeviceUntrustedCertError = errors.New("device app certificate not trusted") // 53
|
||||||
DeviceAppNotInstalled = errors.New("device app not installed") // 59
|
DeviceAppNotInstalled = errors.New("device app not installed") // 59
|
||||||
DeviceGetInfoError = errors.New("device get info error") // 60
|
DeviceGetInfoError = errors.New("device get info error") // 60
|
||||||
DeviceConfigureError = errors.New("device configure error") // 61
|
DeviceConfigureError = errors.New("device configure error") // 61
|
||||||
@@ -179,6 +180,7 @@ var errorsMap = map[error]int{
|
|||||||
DeviceConnectionError: 50,
|
DeviceConnectionError: 50,
|
||||||
DeviceHTTPDriverError: 51,
|
DeviceHTTPDriverError: 51,
|
||||||
DeviceUSBDriverError: 52,
|
DeviceUSBDriverError: 52,
|
||||||
|
DeviceUntrustedCertError: 53,
|
||||||
DeviceAppNotInstalled: 59,
|
DeviceAppNotInstalled: 59,
|
||||||
DeviceGetInfoError: 60,
|
DeviceGetInfoError: 60,
|
||||||
DeviceConfigureError: 61,
|
DeviceConfigureError: 61,
|
||||||
|
|||||||
@@ -7,13 +7,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
hrp "github.com/httprunner/httprunner/v5"
|
hrp "github.com/httprunner/httprunner/v5"
|
||||||
"github.com/httprunner/httprunner/v5/code"
|
"github.com/httprunner/httprunner/v5/code"
|
||||||
"github.com/httprunner/httprunner/v5/internal/builtin"
|
"github.com/httprunner/httprunner/v5/internal/builtin"
|
||||||
"github.com/httprunner/httprunner/v5/internal/config"
|
"github.com/httprunner/httprunner/v5/internal/config"
|
||||||
"github.com/httprunner/httprunner/v5/uixt"
|
"github.com/httprunner/httprunner/v5/uixt"
|
||||||
"github.com/httprunner/httprunner/v5/uixt/option"
|
"github.com/httprunner/httprunner/v5/uixt/option"
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GameElement represents a game element detected in the interface
|
// GameElement represents a game element detected in the interface
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
v5.0.0-250813
|
v5.0.0-250815
|
||||||
|
|||||||
+12
-1
@@ -664,14 +664,22 @@ func (d *Device) installViaABBExec(apk io.ReadSeeker, args ...string) (raw []byt
|
|||||||
tp transport
|
tp transport
|
||||||
filesize int64
|
filesize int64
|
||||||
)
|
)
|
||||||
|
timeout := 8
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(timeout)*time.Minute)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
filesize, err = apk.Seek(0, io.SeekEnd)
|
filesize, err = apk.Seek(0, io.SeekEnd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if tp, err = d.createDeviceTransport(5 * time.Minute); err != nil {
|
if tp, err = d.createDeviceTransport(4 * time.Minute); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer func() { _ = tp.Close() }()
|
defer func() { _ = tp.Close() }()
|
||||||
|
go func() {
|
||||||
|
<-ctx.Done()
|
||||||
|
_ = tp.Close()
|
||||||
|
}()
|
||||||
cmd := "abb_exec:package\x00install\x00-t"
|
cmd := "abb_exec:package\x00install\x00-t"
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
cmd += "\x00" + arg
|
cmd += "\x00" + arg
|
||||||
@@ -690,6 +698,9 @@ func (d *Device) installViaABBExec(apk io.ReadSeeker, args ...string) (raw []byt
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
raw, err = tp.ReadBytesAll()
|
raw, err = tp.ReadBytesAll()
|
||||||
|
if errors.Is(ctx.Err(), context.DeadlineExceeded) {
|
||||||
|
return nil, fmt.Errorf("installation timed out after %d minutes", timeout)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -6,14 +6,14 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v5/internal/builtin"
|
|
||||||
"github.com/httprunner/httprunner/v5/uixt/option"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/httprunner/httprunner/v5/internal/builtin"
|
||||||
|
"github.com/httprunner/httprunner/v5/uixt/option"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestILLMServiceQuery(t *testing.T) {
|
func TestILLMServiceQuery(t *testing.T) {
|
||||||
|
|
||||||
// Create LLM service
|
// Create LLM service
|
||||||
service, err := NewLLMService(option.OPENAI_GPT_4O)
|
service, err := NewLLMService(option.OPENAI_GPT_4O)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -80,7 +80,6 @@ func TestILLMServiceQuery(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestILLMServiceIntegration(t *testing.T) {
|
func TestILLMServiceIntegration(t *testing.T) {
|
||||||
|
|
||||||
// Create LLM service
|
// Create LLM service
|
||||||
service, err := NewLLMService(option.OPENAI_GPT_4O)
|
service, err := NewLLMService(option.OPENAI_GPT_4O)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|||||||
+108
-49
@@ -26,6 +26,7 @@ type WingsService struct {
|
|||||||
bizId string
|
bizId string
|
||||||
accessKey string
|
accessKey string
|
||||||
secretKey string
|
secretKey string
|
||||||
|
history []History // Conversation history for Wings API
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWingsService creates a new Wings service instance
|
// NewWingsService creates a new Wings service instance
|
||||||
@@ -49,6 +50,7 @@ func NewWingsService() (ILLMService, error) {
|
|||||||
bizId: bizID,
|
bizId: bizID,
|
||||||
accessKey: accessKey,
|
accessKey: accessKey,
|
||||||
secretKey: secretKey,
|
secretKey: secretKey,
|
||||||
|
history: []History{},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +61,11 @@ func (w *WingsService) Plan(ctx context.Context, opts *PlanningOptions) (*Planni
|
|||||||
return nil, errors.Wrap(err, "validate planning parameters failed")
|
return nil, errors.Wrap(err, "validate planning parameters failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset history if requested
|
||||||
|
if opts.ResetHistory {
|
||||||
|
w.resetHistory()
|
||||||
|
}
|
||||||
|
|
||||||
// Extract screenshot from message
|
// Extract screenshot from message
|
||||||
screenshot, err := w.extractScreenshotFromMessage(opts.Message)
|
screenshot, err := w.extractScreenshotFromMessage(opts.Message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -70,15 +77,11 @@ func (w *WingsService) Plan(ctx context.Context, opts *PlanningOptions) (*Planni
|
|||||||
|
|
||||||
// Prepare Wings API request
|
// Prepare Wings API request
|
||||||
apiRequest := WingsActionRequest{
|
apiRequest := WingsActionRequest{
|
||||||
Historys: []interface{}{}, // empty as specified
|
Historys: w.history,
|
||||||
DeviceInfos: []WingsDeviceInfo{
|
DeviceInfos: deviceInfo,
|
||||||
deviceInfo,
|
StepText: fmt.Sprintf("%s", opts.UserInstruction),
|
||||||
},
|
|
||||||
StepText: opts.UserInstruction,
|
|
||||||
BizId: w.bizId,
|
BizId: w.bizId,
|
||||||
TextCase: "整体描述:\\n前置条件:\\n获取 1 台设备 A。\\n获取 1 个[万粉创作者]账号a。\\n获取 2 个[普通]账号 b、c。\\n账号 a 和账号 b 互相关注。\\n账号 a 和账号 c 互相关注。\\n账号 a 给账号 b 设置备注为 “11131b”。\\n账号 a 给账号 c 设置备注为 “11131c”。\\n账号 a 创建一个粉丝群 m。\\n 账号 a 修改粉丝群 m 名称为“11131群”。\\n 账号 a 邀请账号 b 加入粉丝群 m。\\n账号 a 邀请账号 c 加入粉丝群 m。\\n账号 a 给群聊 m 发送一条文字消息。\\n设备 A 打开抖音 app。\\n设备 A 登录账号 a。\\n设备 A 退出抖音 app。\\n操作步骤:\\n账号a打开抖音app。\\n点击“消息”。\\n点击“11131群”cell。\\n点击“聊天信息页入口”按钮。\\n点击“分享公开群”按钮。\\n点击文字“群口令”。\\n断言:屏幕中存在文字“口令复制成功”。\\n停止操作。\\n注意事项:\\n",
|
TextCase: fmt.Sprintf("整体描述:\n前置条件:\n操作步骤:\n%s\n停止操作。\n注意事项:\n", opts.UserInstruction),
|
||||||
StepType: "automation",
|
|
||||||
DeviceID: deviceInfo.DeviceID,
|
|
||||||
Base: WingsBase{
|
Base: WingsBase{
|
||||||
LogID: generateWingsUUID(),
|
LogID: generateWingsUUID(),
|
||||||
},
|
},
|
||||||
@@ -98,7 +101,7 @@ func (w *WingsService) Plan(ctx context.Context, opts *PlanningOptions) (*Planni
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check API response status
|
// Check API response status
|
||||||
if response.BaseResp.StatusCode != 0 {
|
if response.BaseResp.StatusCode != 0 && response.BaseResp.StatusCode != 200 {
|
||||||
err = fmt.Errorf("API returned error: %s", response.BaseResp.StatusMessage)
|
err = fmt.Errorf("API returned error: %s", response.BaseResp.StatusMessage)
|
||||||
return &PlanningResult{
|
return &PlanningResult{
|
||||||
Thought: response.ThoughtChain.Thought,
|
Thought: response.ThoughtChain.Thought,
|
||||||
@@ -107,8 +110,23 @@ func (w *WingsService) Plan(ctx context.Context, opts *PlanningOptions) (*Planni
|
|||||||
}, err
|
}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update history with response data
|
||||||
|
newHistoryEntry := History{
|
||||||
|
ThoughtChain: response.ThoughtChain,
|
||||||
|
StepText: response.StepText,
|
||||||
|
StepTextTrans: response.StepTextTrans,
|
||||||
|
OriStepIndex: response.OriStepIndex,
|
||||||
|
DeviceID: deviceInfo[0].DeviceID,
|
||||||
|
AgentType: response.AgentType,
|
||||||
|
ActionResult: "", // Always empty as requested
|
||||||
|
DeviceInfos: &deviceInfo,
|
||||||
|
ActionParams: response.ActionParams,
|
||||||
|
}
|
||||||
|
w.history = append(w.history, newHistoryEntry)
|
||||||
|
var toolCalls []schema.ToolCall
|
||||||
|
if response.StepType != "FINISH" {
|
||||||
// Convert Wings API response to tool calls
|
// Convert Wings API response to tool calls
|
||||||
toolCalls, err := w.convertWingsResponseToToolCalls(response.ActionParams)
|
toolCalls, err = w.convertWingsResponseToToolCalls(response.ActionParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &PlanningResult{
|
return &PlanningResult{
|
||||||
Thought: response.ThoughtChain.Thought,
|
Thought: response.ThoughtChain.Thought,
|
||||||
@@ -116,17 +134,24 @@ func (w *WingsService) Plan(ctx context.Context, opts *PlanningOptions) (*Planni
|
|||||||
ModelName: "wings-api",
|
ModelName: "wings-api",
|
||||||
}, errors.Wrap(err, "convert Wings response to tool calls failed")
|
}, errors.Wrap(err, "convert Wings response to tool calls failed")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No need to update ActionResult as per user request
|
||||||
|
// ActionResult should always be empty
|
||||||
|
|
||||||
log.Info().
|
log.Info().
|
||||||
Str("thought", response.ThoughtChain.Thought).
|
Str("thought", response.ThoughtChain.Thought).
|
||||||
|
Str("action", response.AgentType).
|
||||||
|
Str("action_params", response.ActionParams).
|
||||||
|
Str("log_id", fmt.Sprintf("%v", response.BaseResp.Extra)).
|
||||||
Int("tool_calls_count", len(toolCalls)).
|
Int("tool_calls_count", len(toolCalls)).
|
||||||
Int64("elapsed_ms", elapsed).
|
Int64("elapsed_ms", elapsed).
|
||||||
Msg("Wings API planning completed")
|
Msg("Wings API planning completed")
|
||||||
|
|
||||||
return &PlanningResult{
|
return &PlanningResult{
|
||||||
ToolCalls: toolCalls,
|
ToolCalls: toolCalls,
|
||||||
Thought: response.ThoughtChain.Thought,
|
Thought: response.StepTextTrans,
|
||||||
Content: response.ThoughtChain.Summary,
|
Content: response.StepTextTrans,
|
||||||
ModelName: "wings-api",
|
ModelName: "wings-api",
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@@ -138,28 +163,20 @@ func (w *WingsService) Assert(ctx context.Context, opts *AssertOptions) (*Assert
|
|||||||
return nil, errors.Wrap(err, "validate assertion parameters failed")
|
return nil, errors.Wrap(err, "validate assertion parameters failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean screenshot data URL prefix
|
|
||||||
cleanScreenshot := w.cleanScreenshotDataURL(opts.Screenshot)
|
|
||||||
|
|
||||||
// Get device info from context (if available)
|
// Get device info from context (if available)
|
||||||
deviceInfo := w.getDeviceInfoFromScreenshot(ctx, cleanScreenshot)
|
deviceInfos := w.getDeviceInfoFromScreenshot(ctx, opts.Screenshot)
|
||||||
|
|
||||||
// Prepare Wings API request for assertion
|
// Prepare Wings API request for assertion
|
||||||
apiRequest := WingsActionRequest{
|
apiRequest := WingsActionRequest{
|
||||||
Historys: []interface{}{}, // empty as specified
|
Historys: []History{},
|
||||||
DeviceInfos: []WingsDeviceInfo{
|
DeviceInfos: deviceInfos,
|
||||||
deviceInfo,
|
StepText: fmt.Sprintf("断言:%s", opts.Assertion),
|
||||||
},
|
|
||||||
StepText: opts.Assertion,
|
|
||||||
BizId: w.bizId,
|
BizId: w.bizId,
|
||||||
TextCase: "整体描述:\\n前置条件:\\n获取 1 台设备 A。\\n获取 1 个[万粉创作者]账号a。\\n获取 2 个[普通]账号 b、c。\\n账号 a 和账号 b 互相关注。\\n账号 a 和账号 c 互相关注。\\n账号 a 给账号 b 设置备注为 “11131b”。\\n账号 a 给账号 c 设置备注为 “11131c”。\\n账号 a 创建一个粉丝群 m。\\n 账号 a 修改粉丝群 m 名称为“11131群”。\\n 账号 a 邀请账号 b 加入粉丝群 m。\\n账号 a 邀请账号 c 加入粉丝群 m。\\n账号 a 给群聊 m 发送一条文字消息。\\n设备 A 打开抖音 app。\\n设备 A 登录账号 a。\\n设备 A 退出抖音 app。\\n操作步骤:\\n账号a打开抖音app。\\n点击“消息”。\\n点击“11131群”cell。\\n点击“聊天信息页入口”按钮。\\n点击“分享公开群”按钮。\\n点击文字“群口令”。\\n断言:屏幕中存在文字“口令复制成功”。\\n停止操作。\\n注意事项:\\n",
|
TextCase: fmt.Sprintf("整体描述:\n前置条件:\n操作步骤:\n断言: %s\n停止操作。\n注意事项:\n", opts.Assertion),
|
||||||
StepType: "assert", // Different from automation
|
|
||||||
DeviceID: deviceInfo.DeviceID,
|
|
||||||
Base: WingsBase{
|
Base: WingsBase{
|
||||||
LogID: generateWingsUUID(),
|
LogID: generateWingsUUID(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
log.Info().Interface("apiRequest", apiRequest).Msg("Wings API request")
|
|
||||||
|
|
||||||
// Call Wings API
|
// Call Wings API
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
@@ -175,7 +192,7 @@ func (w *WingsService) Assert(ctx context.Context, opts *AssertOptions) (*Assert
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check API response status
|
// Check API response status
|
||||||
if response.BaseResp.StatusCode != 0 {
|
if response.BaseResp.StatusCode != 0 && response.BaseResp.StatusCode != 200 {
|
||||||
err = fmt.Errorf("API returned error: %s", response.BaseResp.StatusMessage)
|
err = fmt.Errorf("API returned error: %s", response.BaseResp.StatusMessage)
|
||||||
return &AssertionResult{
|
return &AssertionResult{
|
||||||
Pass: false,
|
Pass: false,
|
||||||
@@ -184,6 +201,19 @@ func (w *WingsService) Assert(ctx context.Context, opts *AssertOptions) (*Assert
|
|||||||
}, err
|
}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update history with response data
|
||||||
|
newHistoryEntry := History{
|
||||||
|
ThoughtChain: response.ThoughtChain,
|
||||||
|
StepText: response.StepText,
|
||||||
|
StepTextTrans: response.StepTextTrans,
|
||||||
|
OriStepIndex: response.OriStepIndex,
|
||||||
|
DeviceID: response.DeviceId,
|
||||||
|
AgentType: response.AgentType,
|
||||||
|
DeviceInfos: &apiRequest.DeviceInfos,
|
||||||
|
ActionParams: response.ActionParams,
|
||||||
|
}
|
||||||
|
w.history = append(w.history, newHistoryEntry)
|
||||||
|
|
||||||
// Parse assertion result from action_params
|
// Parse assertion result from action_params
|
||||||
passed, assertionThought, err := w.parseAssertionResult(response.ActionParams, response.ThoughtChain)
|
passed, assertionThought, err := w.parseAssertionResult(response.ActionParams, response.ThoughtChain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -194,6 +224,9 @@ func (w *WingsService) Assert(ctx context.Context, opts *AssertOptions) (*Assert
|
|||||||
}, errors.Wrap(err, "parse assertion result failed")
|
}, errors.Wrap(err, "parse assertion result failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No need to update ActionResult as per user request
|
||||||
|
// ActionResult should always be empty
|
||||||
|
|
||||||
log.Info().
|
log.Info().
|
||||||
Bool("passed", passed).
|
Bool("passed", passed).
|
||||||
Str("thought", assertionThought).
|
Str("thought", assertionThought).
|
||||||
@@ -228,13 +261,12 @@ func (w *WingsService) RegisterTools(tools []*schema.ToolInfo) error {
|
|||||||
|
|
||||||
// Wings API data structures
|
// Wings API data structures
|
||||||
type WingsActionRequest struct {
|
type WingsActionRequest struct {
|
||||||
Historys []interface{} `json:"historys"`
|
Historys []History `json:"historys"`
|
||||||
DeviceInfos []WingsDeviceInfo `json:"device_infos"`
|
DeviceInfos []WingsDeviceInfo `json:"device_infos"`
|
||||||
StepText string `json:"step_text"`
|
StepText string `json:"step_text"`
|
||||||
BizId string `json:"biz_id"`
|
|
||||||
TextCase string `json:"text_case"`
|
TextCase string `json:"text_case"`
|
||||||
StepType string `json:"step_type"`
|
BizId string `json:"biz_id"`
|
||||||
DeviceID string `json:"device_id"`
|
TaskType string `json:"task_type"`
|
||||||
Base WingsBase `json:"Base"`
|
Base WingsBase `json:"Base"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,8 +285,14 @@ type WingsBase struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type WingsActionResponse struct {
|
type WingsActionResponse struct {
|
||||||
|
AgentType string `json:"agent_type"`
|
||||||
|
StepText string `json:"step_text"`
|
||||||
|
StepTextTrans string `json:"step_text_trans"`
|
||||||
|
OriStepIndex int `json:"ori_step_index"`
|
||||||
StepType string `json:"step_type"`
|
StepType string `json:"step_type"`
|
||||||
ActionParams string `json:"action_params"`
|
ActionParams string `json:"action_params"`
|
||||||
|
DeviceId string `json:"device_id"`
|
||||||
|
NextIsFinish bool `json:"next_is_finish"`
|
||||||
ThoughtChain WingsThoughtChain `json:"thought_chain"`
|
ThoughtChain WingsThoughtChain `json:"thought_chain"`
|
||||||
BaseResp WingsBaseResp `json:"BaseResp"`
|
BaseResp WingsBaseResp `json:"BaseResp"`
|
||||||
}
|
}
|
||||||
@@ -276,6 +314,19 @@ type WingsExtra struct {
|
|||||||
LogID string `json:"_log_id"`
|
LogID string `json:"_log_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// History structure for request and response
|
||||||
|
type History struct {
|
||||||
|
ThoughtChain WingsThoughtChain `json:"thought_chain"` // 思考结果
|
||||||
|
StepText string `json:"step_text"` // 操作的指令
|
||||||
|
DeviceID string `json:"device_id"` // 操作的设备id
|
||||||
|
AgentType string `json:"agent_type"` // 最终决策的agent类型
|
||||||
|
ActionResult string `json:"action_result"` // 操作结果, 断言=断言结果, 自动化=自动化操作是否成功, 物料构造=物料构造结果
|
||||||
|
DeviceInfos *[]WingsDeviceInfo `json:"device_infos"` // 所有设备的信息
|
||||||
|
ActionParams string `json:"action_params"` // 历史操作解析结果(断言,自动化,物料构造)
|
||||||
|
StepTextTrans string `json:"step_text_trans"` // 归一化的步骤文本(为后续的实际执行解析文本)
|
||||||
|
OriStepIndex int `json:"ori_step_index"` // 原本的执行序列(扩展前、目标导向原始文本步骤)
|
||||||
|
}
|
||||||
|
|
||||||
// Action parameter structures
|
// Action parameter structures
|
||||||
type WingsActionParams struct {
|
type WingsActionParams struct {
|
||||||
Type string `json:"Type"`
|
Type string `json:"Type"`
|
||||||
@@ -315,6 +366,11 @@ type WingsTextParams struct {
|
|||||||
|
|
||||||
// Helper methods
|
// Helper methods
|
||||||
|
|
||||||
|
// resetHistory resets the conversation history
|
||||||
|
func (w *WingsService) resetHistory() {
|
||||||
|
w.history = []History{}
|
||||||
|
}
|
||||||
|
|
||||||
// generateWingsUUID generates a random UUID for LogID
|
// generateWingsUUID generates a random UUID for LogID
|
||||||
func generateWingsUUID() string {
|
func generateWingsUUID() string {
|
||||||
return uuid.New().String()
|
return uuid.New().String()
|
||||||
@@ -328,16 +384,7 @@ func (w *WingsService) extractScreenshotFromMessage(message *schema.Message) (st
|
|||||||
|
|
||||||
for _, content := range message.MultiContent {
|
for _, content := range message.MultiContent {
|
||||||
if content.Type == schema.ChatMessagePartTypeImageURL && content.ImageURL != nil {
|
if content.Type == schema.ChatMessagePartTypeImageURL && content.ImageURL != nil {
|
||||||
// Extract base64 data from data URL
|
return content.ImageURL.URL, nil
|
||||||
screenshot := content.ImageURL.URL
|
|
||||||
if strings.HasPrefix(screenshot, "data:image/") {
|
|
||||||
// Remove data URL prefix
|
|
||||||
parts := strings.Split(screenshot, ",")
|
|
||||||
if len(parts) == 2 {
|
|
||||||
return parts[1], nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return screenshot, nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,19 +392,29 @@ func (w *WingsService) extractScreenshotFromMessage(message *schema.Message) (st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getDeviceInfoFromContext gets device info from context with fallback
|
// getDeviceInfoFromContext gets device info from context with fallback
|
||||||
func (w *WingsService) getDeviceInfoFromContext(_ context.Context, screenshot string) WingsDeviceInfo {
|
func (w *WingsService) getDeviceInfoFromContext(_ context.Context, screenshot string) []WingsDeviceInfo {
|
||||||
// use default device info
|
// TODO: Extract device info from context if available
|
||||||
return WingsDeviceInfo{
|
|
||||||
|
// Use last history's NowImage as PreImage if history exists
|
||||||
|
preImageUrl := screenshot
|
||||||
|
if len(w.history) > 0 && w.history[len(w.history)-1].DeviceInfos != nil && len(*w.history[len(w.history)-1].DeviceInfos) > 0 {
|
||||||
|
preImageUrl = (*w.history[len(w.history)-1].DeviceInfos)[0].NowImageUrl
|
||||||
|
}
|
||||||
|
|
||||||
|
// use default device info with optimized PreImage
|
||||||
|
return []WingsDeviceInfo{
|
||||||
|
{
|
||||||
DeviceID: "default-device",
|
DeviceID: "default-device",
|
||||||
NowImage: screenshot,
|
NowImageUrl: screenshot,
|
||||||
PreImage: screenshot,
|
PreImageUrl: preImageUrl,
|
||||||
NowLayoutJSON: "",
|
NowLayoutJSON: "",
|
||||||
OperationSystem: "android",
|
OperationSystem: "android",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getDeviceInfoFromScreenshot gets device info from screenshot (for Assert)
|
// getDeviceInfoFromScreenshot gets device info from screenshot (for Assert)
|
||||||
func (w *WingsService) getDeviceInfoFromScreenshot(ctx context.Context, screenshot string) WingsDeviceInfo {
|
func (w *WingsService) getDeviceInfoFromScreenshot(ctx context.Context, screenshot string) []WingsDeviceInfo {
|
||||||
return w.getDeviceInfoFromContext(ctx, screenshot)
|
return w.getDeviceInfoFromContext(ctx, screenshot)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,6 +447,8 @@ func (w *WingsService) callWingsAPI(ctx context.Context, request WingsActionRequ
|
|||||||
// Set headers
|
// Set headers
|
||||||
httpReq.Header.Set("Content-Type", "application/json")
|
httpReq.Header.Set("Content-Type", "application/json")
|
||||||
httpReq.Header.Set("Accept", "application/json")
|
httpReq.Header.Set("Accept", "application/json")
|
||||||
|
httpReq.Header.Add("x-use-ppe", "1")
|
||||||
|
httpReq.Header.Add("x-tt-env", "ppe_refactor_merge")
|
||||||
|
|
||||||
// Add authentication headers if using external API
|
// Add authentication headers if using external API
|
||||||
if w.accessKey != "" && w.secretKey != "" {
|
if w.accessKey != "" && w.secretKey != "" {
|
||||||
@@ -403,7 +462,7 @@ func (w *WingsService) callWingsAPI(ctx context.Context, request WingsActionRequ
|
|||||||
|
|
||||||
// Execute HTTP request
|
// Execute HTTP request
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Timeout: 60 * time.Second,
|
Timeout: 120 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := client.Do(httpReq)
|
resp, err := client.Do(httpReq)
|
||||||
@@ -413,7 +472,7 @@ func (w *WingsService) callWingsAPI(ctx context.Context, request WingsActionRequ
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
logID := resp.Header.Get("X-Tt-Logid")
|
logID := resp.Header.Get("X-Tt-Logid")
|
||||||
log.Info().Str("step_text", request.StepText).Str("log_id", logID).Str("biz_id", request.BizId).Str("url", w.apiURL).Msg("call wings api")
|
log.Info().Str("step_text", request.StepText).Str("image_url", request.DeviceInfos[0].NowImageUrl).Str("log_id", logID).Str("biz_id", request.BizId).Str("url", w.apiURL).Msg("call wings api")
|
||||||
|
|
||||||
// Read response body
|
// Read response body
|
||||||
responseBody, err := io.ReadAll(resp.Body)
|
responseBody, err := io.ReadAll(resp.Body)
|
||||||
@@ -437,7 +496,7 @@ func (w *WingsService) callWingsAPI(ctx context.Context, request WingsActionRequ
|
|||||||
|
|
||||||
// convertWingsResponseToToolCalls converts Wings API response to tool calls using generic approach
|
// convertWingsResponseToToolCalls converts Wings API response to tool calls using generic approach
|
||||||
func (w *WingsService) convertWingsResponseToToolCalls(actionParamsStr string) ([]schema.ToolCall, error) {
|
func (w *WingsService) convertWingsResponseToToolCalls(actionParamsStr string) ([]schema.ToolCall, error) {
|
||||||
if actionParamsStr == "" {
|
if actionParamsStr == "" || actionParamsStr == "FINISH" {
|
||||||
return []schema.ToolCall{}, nil
|
return []schema.ToolCall{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -240,12 +240,12 @@ func (dev *AndroidDevice) installViaInstaller(apkPath string, args ...string) er
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// 等待安装完成或超时
|
// 等待安装完成或超时
|
||||||
timeout := 3 * time.Minute
|
timeout := 8 * time.Minute
|
||||||
select {
|
select {
|
||||||
case err := <-done:
|
case err := <-done:
|
||||||
return err
|
return err
|
||||||
case <-time.After(timeout):
|
case <-time.After(timeout):
|
||||||
return fmt.Errorf("installation timed out after %v", timeout)
|
return fmt.Errorf("install via installer timed out after %v", timeout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -251,6 +251,7 @@ func (dExt *XTDriver) AIAssert(assertion string, opts ...option.ActionOption) (*
|
|||||||
screenResult, err := dExt.GetScreenResult(
|
screenResult, err := dExt.GetScreenResult(
|
||||||
option.WithScreenShotFileName("ai_assert"),
|
option.WithScreenShotFileName("ai_assert"),
|
||||||
option.WithScreenShotBase64(true),
|
option.WithScreenShotBase64(true),
|
||||||
|
option.WithScreenShotUpload(true),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -267,7 +268,7 @@ func (dExt *XTDriver) AIAssert(assertion string, opts ...option.ActionOption) (*
|
|||||||
modelCallStartTime := time.Now()
|
modelCallStartTime := time.Now()
|
||||||
assertOpts := &ai.AssertOptions{
|
assertOpts := &ai.AssertOptions{
|
||||||
Assertion: assertion,
|
Assertion: assertion,
|
||||||
Screenshot: screenResult.Base64,
|
Screenshot: screenResult.UploadedURL,
|
||||||
Size: screenResult.Resolution,
|
Size: screenResult.Resolution,
|
||||||
}
|
}
|
||||||
result, err := dExt.LLMService.Assert(context.Background(), assertOpts)
|
result, err := dExt.LLMService.Assert(context.Background(), assertOpts)
|
||||||
@@ -302,6 +303,7 @@ func (dExt *XTDriver) PlanNextAction(ctx context.Context, prompt string, opts ..
|
|||||||
screenResult, err := dExt.GetScreenResult(
|
screenResult, err := dExt.GetScreenResult(
|
||||||
option.WithScreenShotFileName("ai_planning"),
|
option.WithScreenShotFileName("ai_planning"),
|
||||||
option.WithScreenShotBase64(true),
|
option.WithScreenShotBase64(true),
|
||||||
|
option.WithScreenShotUpload(true),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -321,7 +323,7 @@ func (dExt *XTDriver) PlanNextAction(ctx context.Context, prompt string, opts ..
|
|||||||
{
|
{
|
||||||
Type: schema.ChatMessagePartTypeImageURL,
|
Type: schema.ChatMessagePartTypeImageURL,
|
||||||
ImageURL: &schema.ChatMessageImageURL{
|
ImageURL: &schema.ChatMessageImageURL{
|
||||||
URL: screenResult.Base64,
|
URL: screenResult.UploadedURL,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -134,6 +134,19 @@ func (dExt *XTDriver) GetScreenResult(opts ...option.ActionOption) (screenResult
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if screenshotOptions.ScreenShotWithUpload {
|
||||||
|
// Upload the screenshot to the server
|
||||||
|
if screenResult.ImagePath != "" && screenResult.bufSource != nil {
|
||||||
|
url, err := uploadScreenshot(screenResult.ImagePath, screenResult.bufSource)
|
||||||
|
if err != nil {
|
||||||
|
log.Warn().Err(err).Str("imagePath", screenResult.ImagePath).Msg("failed to upload screenshot")
|
||||||
|
} else if url != "" {
|
||||||
|
screenResult.UploadedURL = url
|
||||||
|
log.Info().Str("uploadedUrl", url).Msg("screenshot uploaded successfully")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// save screen result to session
|
// save screen result to session
|
||||||
session := dExt.GetSession()
|
session := dExt.GetSession()
|
||||||
session.screenResults = append(session.screenResults, screenResult)
|
session.screenResults = append(session.screenResults, screenResult)
|
||||||
|
|||||||
+12
-2
@@ -41,7 +41,7 @@ type DriverRequests struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewDriverSession() *DriverSession {
|
func NewDriverSession() *DriverSession {
|
||||||
timeout := 30 * time.Second
|
timeout := 120 * time.Second
|
||||||
session := &DriverSession{
|
session := &DriverSession{
|
||||||
ctx: context.Background(),
|
ctx: context.Background(),
|
||||||
ID: "<SessionNotInit>",
|
ID: "<SessionNotInit>",
|
||||||
@@ -202,8 +202,13 @@ func (s *DriverSession) RequestWithRetry(method string, urlStr string, rawBody [
|
|||||||
synthesizeEventRetryAdded = true
|
synthesizeEventRetryAdded = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notice: use DeviceHTTPDriverError when request driver failed
|
// Check if it's already a DeviceOfflineError
|
||||||
|
if errors.Is(err, code.DeviceOfflineError) {
|
||||||
|
lastError = err
|
||||||
|
} else {
|
||||||
|
// Use DeviceHTTPDriverError for other errors
|
||||||
lastError = errors.Wrap(code.DeviceHTTPDriverError, err.Error())
|
lastError = errors.Wrap(code.DeviceHTTPDriverError, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
// If this was the last attempt, break
|
// If this was the last attempt, break
|
||||||
if attempt == maxRetry {
|
if attempt == maxRetry {
|
||||||
@@ -296,6 +301,11 @@ func (s *DriverSession) Request(method string, urlStr string, rawBody []byte, op
|
|||||||
driverResult.RequestTime = time.Now()
|
driverResult.RequestTime = time.Now()
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
if resp, err = s.client.Do(req); err != nil {
|
if resp, err = s.client.Do(req); err != nil {
|
||||||
|
// Check for connection reset or EOF errors and classify as DeviceOfflineError
|
||||||
|
if strings.Contains(err.Error(), "read: connection reset by peer") ||
|
||||||
|
strings.Contains(err.Error(), "EOF") {
|
||||||
|
return nil, errors.Wrap(code.DeviceOfflineError, err.Error())
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|||||||
+85
-5
@@ -1,11 +1,14 @@
|
|||||||
package uixt
|
package uixt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/rand/v2"
|
"math/rand/v2"
|
||||||
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -18,6 +21,7 @@ import (
|
|||||||
"github.com/httprunner/httprunner/v5/code"
|
"github.com/httprunner/httprunner/v5/code"
|
||||||
"github.com/httprunner/httprunner/v5/internal/builtin"
|
"github.com/httprunner/httprunner/v5/internal/builtin"
|
||||||
"github.com/httprunner/httprunner/v5/internal/config"
|
"github.com/httprunner/httprunner/v5/internal/config"
|
||||||
|
"github.com/httprunner/httprunner/v5/internal/json"
|
||||||
"github.com/httprunner/httprunner/v5/uixt/option"
|
"github.com/httprunner/httprunner/v5/uixt/option"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -350,34 +354,110 @@ func DownloadFileByUrl(fileUrl string) (filePath string, err error) {
|
|||||||
// Build the HTTP GET request.
|
// Build the HTTP GET request.
|
||||||
req, err := http.NewRequest("GET", fileUrl, nil)
|
req, err := http.NewRequest("GET", fileUrl, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", errors.Wrap(code.NetworkError, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform the request.
|
// Perform the request.
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", errors.Wrap(code.NetworkError, err.Error())
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
// Check the HTTP status code.
|
// Check the HTTP status code.
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return "", fmt.Errorf("failed to download file: %s", resp.Status)
|
return "", errors.Wrap(code.NetworkError, fmt.Errorf("failed to download file: %s", resp.Status).Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the output file.
|
// Create the output file.
|
||||||
outFile, err := os.Create(filePath)
|
outFile, err := os.Create(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", errors.Wrap(code.MobileUIDriverError, err.Error())
|
||||||
}
|
}
|
||||||
defer outFile.Close()
|
defer outFile.Close()
|
||||||
|
|
||||||
// Copy the response body to the file.
|
// Copy the response body to the file.
|
||||||
_, err = io.Copy(outFile, resp.Body)
|
_, err = io.Copy(outFile, resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", errors.Wrap(code.NetworkError, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info().Str("filePath", filePath).Msg("download file success")
|
log.Info().Str("filePath", filePath).Msg("download file success")
|
||||||
return filePath, nil
|
return filePath, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// uploadScreenshot uploads a screenshot to the server and returns the URL
|
||||||
|
func uploadScreenshot(imagePath string, imageBuffer *bytes.Buffer) (string, error) {
|
||||||
|
// Create a new buffer for the multipart form
|
||||||
|
var requestBody bytes.Buffer
|
||||||
|
writer := multipart.NewWriter(&requestBody)
|
||||||
|
|
||||||
|
// Create a form file field
|
||||||
|
fileField, err := writer.CreateFormFile("file", filepath.Base(imagePath))
|
||||||
|
if err != nil {
|
||||||
|
return "", errors.Wrap(err, "failed to create form file")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy the image buffer to the form file field
|
||||||
|
if _, err := io.Copy(fileField, bytes.NewReader(imageBuffer.Bytes())); err != nil {
|
||||||
|
return "", errors.Wrap(err, "failed to copy image data")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the multipart writer
|
||||||
|
if err := writer.Close(); err != nil {
|
||||||
|
return "", errors.Wrap(err, "failed to close multipart writer")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the HTTP request
|
||||||
|
uploadURL := "https://gtf-eapi-cn.bytedance.com/cn/upload/xxx"
|
||||||
|
req, err := http.NewRequest("POST", uploadURL, &requestBody)
|
||||||
|
if err != nil {
|
||||||
|
return "", errors.Wrap(code.UploadFailed, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set headers
|
||||||
|
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||||
|
req.Header.Set("accessKey", "ies.vedem.video")
|
||||||
|
req.Header.Set("token", "***REMOVED***")
|
||||||
|
|
||||||
|
// Create HTTP client with HTTP/1.1 support
|
||||||
|
client := &http.Client{
|
||||||
|
Transport: &http.Transport{
|
||||||
|
TLSNextProto: make(map[string]func(authority string, c *tls.Conn) http.RoundTripper),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the request
|
||||||
|
log.Debug().Str("url", uploadURL).Str("imagePath", imagePath).Msg("uploading screenshot")
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", errors.Wrap(code.UploadFailed, err.Error())
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
// Read the response body
|
||||||
|
respBody, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return "", errors.Wrap(code.UploadFailed, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse the response JSON
|
||||||
|
var result struct {
|
||||||
|
StatusCode int `json:"StatusCode"`
|
||||||
|
Data interface{} `json:"Data"`
|
||||||
|
URL string `json:"URL"`
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := json.Unmarshal(respBody, &result); err != nil {
|
||||||
|
log.Warn().Err(err).Str("response", string(respBody)).Msg("failed to parse upload response")
|
||||||
|
return "", errors.Wrap(code.UploadFailed, "failed to parse response JSON")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the upload was successful
|
||||||
|
if result.StatusCode != 0 {
|
||||||
|
return "", fmt.Errorf("upload failed with status code: %d", result.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debug().Str("url", result.URL).Msg("screenshot uploaded successfully")
|
||||||
|
return result.URL, nil
|
||||||
|
}
|
||||||
|
|||||||
Binary file not shown.
+15
-1
@@ -437,6 +437,13 @@ func (wd *WDADriver) AppLaunch(bundleId string) (err error) {
|
|||||||
// 超时两分钟
|
// 超时两分钟
|
||||||
_, err = wd.Session.POST(data, "/wings/apps/launch", option.WithTimeout(120))
|
_, err = wd.Session.POST(data, "/wings/apps/launch", option.WithTimeout(120))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// Check for untrusted certificate error
|
||||||
|
errMsg := err.Error()
|
||||||
|
if strings.Contains(errMsg, "has not been explicitly trusted by the user") ||
|
||||||
|
strings.Contains(errMsg, "invalid code signature") ||
|
||||||
|
strings.Contains(errMsg, "inadequate entitlements") {
|
||||||
|
return errors.Wrap(code.DeviceUntrustedCertError, "App certificate not trusted: "+bundleId)
|
||||||
|
}
|
||||||
return errors.Wrap(err, "wda app launch failed")
|
return errors.Wrap(err, "wda app launch failed")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -444,10 +451,17 @@ func (wd *WDADriver) AppLaunch(bundleId string) (err error) {
|
|||||||
|
|
||||||
func (wd *WDADriver) AppLaunchUnattached(bundleId string) (err error) {
|
func (wd *WDADriver) AppLaunchUnattached(bundleId string) (err error) {
|
||||||
log.Info().Str("bundleId", bundleId).Msg("WDADriver.AppLaunchUnattached")
|
log.Info().Str("bundleId", bundleId).Msg("WDADriver.AppLaunchUnattached")
|
||||||
// [[FBRoute POST:@"/wda/apps/launchUnattached"].withoutSession respondWithTarget:self action:@selector(handleLaunchUnattachedApp:)]
|
// [[FBRoute POST:@"/wda/apps/launchUnattached"].withoutSession respondWithTarget:self action:@selector(handleLaunchUnattachedApp:)]]
|
||||||
data := map[string]interface{}{"bundleId": bundleId}
|
data := map[string]interface{}{"bundleId": bundleId}
|
||||||
_, err = wd.Session.POST(data, "/wda/apps/launchUnattached")
|
_, err = wd.Session.POST(data, "/wda/apps/launchUnattached")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// Check for untrusted certificate error
|
||||||
|
errMsg := err.Error()
|
||||||
|
if strings.Contains(errMsg, "has not been explicitly trusted by the user") ||
|
||||||
|
strings.Contains(errMsg, "invalid code signature") ||
|
||||||
|
strings.Contains(errMsg, "inadequate entitlements") {
|
||||||
|
return errors.Wrap(code.DeviceUntrustedCertError, "App certificate not trusted: "+bundleId)
|
||||||
|
}
|
||||||
return errors.Wrap(err, "wda app launchUnattached failed")
|
return errors.Wrap(err, "wda app launchUnattached failed")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user