mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-10 23:12:41 +08:00
feat: add PushImage/ClearImages in IDriver
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -926,6 +927,33 @@ func (wd *WDADriver) StartCaptureLog(identifier ...string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (wd *WDADriver) PushImage(localPath string) error {
|
||||
localFile, err := os.Open(localPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer localFile.Close()
|
||||
|
||||
imageBytes, err := io.ReadAll(localFile)
|
||||
data := map[string]interface{}{
|
||||
"file_name": path.Base(localPath),
|
||||
"file_data": base64.StdEncoding.EncodeToString(imageBytes),
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = wd.Session.POST(data, "/gtf/albums/add")
|
||||
return err
|
||||
}
|
||||
|
||||
func (wd *WDADriver) ClearImages() error {
|
||||
data := map[string]interface{}{}
|
||||
|
||||
_, err := wd.Session.POST(data, "/gtf/albums/clear")
|
||||
return err
|
||||
}
|
||||
|
||||
type wdaResponse struct {
|
||||
Status int `json:"status"`
|
||||
SessionID string `json:"sessionId"`
|
||||
|
||||
Reference in New Issue
Block a user