feat: 新增设置粘贴板

This commit is contained in:
余泓铮
2024-06-13 15:09:30 +08:00
parent c5712b1a66
commit 30d4dcbaa2
2 changed files with 12 additions and 1 deletions

View File

@@ -1 +1 @@
v4.5.6
v4.5.7

View File

@@ -26,6 +26,8 @@ const (
ACTION_SleepRandom ActionMethod = "sleep_random"
ACTION_StartCamera ActionMethod = "camera_start" // alias for app_launch camera
ACTION_StopCamera ActionMethod = "camera_stop" // alias for app_terminate camera
ACTION_SetClipboard ActionMethod = "set_clipboard"
ACTION_GetClipboard ActionMethod = "get_clipboard"
// UI validation
// selectors
@@ -594,6 +596,15 @@ func (dExt *DriverExt) DoAction(action MobileAction) (err error) {
return nil
}
return fmt.Errorf("app_terminate params should be bundleId(string), got %v", action.Params)
case ACTION_SetClipboard:
if text, ok := action.Params.(string); ok {
err := dExt.Driver.SetPasteboard(PasteboardTypePlaintext, text)
if err != nil {
return errors.Wrap(err, "failed to set clipboard")
}
return nil
}
return fmt.Errorf("set_clioboard params should be text(string), got %v", action.Params)
case ACTION_Home:
return dExt.Driver.Homescreen()
case ACTION_TapXY: