fix: rename browser_web_driver to browser_driver

This commit is contained in:
lilong.129 2025-03-03 21:27:32 +08:00
parent 720e5fa504
commit 69d06a7215
4 changed files with 15 additions and 18 deletions

View File

@ -1 +1 @@
v5.0.0+2503032117
v5.0.0+2503032127

View File

@ -2,16 +2,19 @@ package uixt
import (
"bytes"
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
"github.com/httprunner/httprunner/v5/pkg/uixt/types"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
"github.com/httprunner/httprunner/v5/pkg/uixt/types"
)
type BrowserDevice struct {
BrowserId string `json:"browser_id,omitempty" yaml:"browser_id,omitempty"`
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
}
type BrowserDeviceOption func(*BrowserDevice)
func WithBrowserId(serial string) BrowserDeviceOption {

View File

@ -12,10 +12,11 @@ import (
"time"
"github.com/gorilla/websocket"
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
"github.com/httprunner/httprunner/v5/pkg/uixt/types"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
"github.com/httprunner/httprunner/v5/pkg/uixt/types"
)
const BROWSER_LOCAL_ADDRESS = "localhost:8093"
@ -71,8 +72,7 @@ func CreateBrowser(timeout int) (browserInfo *BrowserInfo, err error) {
return nil, err
}
rawResp, err := io.ReadAll(resp.Body)
rawResp, _ := io.ReadAll(resp.Body)
if resp.StatusCode != http.StatusOK {
return nil, errors.New(resp.Status)
}
@ -96,13 +96,7 @@ func NewBrowserWebDriver(browserId string) (driver *BrowserWebDriver, err error)
driver.urlPrefix.Host = BROWSER_LOCAL_ADDRESS
driver.urlPrefix.Scheme = "http"
driver.scale = 1.0
if err != nil {
return nil, errors.Wrap(err, "create browser session failed")
}
driver.sessionId = browserId
if err != nil {
return nil, fmt.Errorf("adb forward: %w", err)
}
return driver, nil
}
@ -148,8 +142,7 @@ func (wd *BrowserWebDriver) DeleteSession() (err error) {
return err
}
rawResp, err := io.ReadAll(resp.Body)
rawResp, _ := io.ReadAll(resp.Body)
if resp.StatusCode != http.StatusOK {
return errors.New(resp.Status)
}
@ -185,7 +178,7 @@ func (wd *BrowserWebDriver) CreateNetListener() (*websocket.Conn, error) {
"context_id":"%v"
}`, wd.sessionId)
err = c.WriteMessage(websocket.TextMessage, []byte(initMessage))
return c, nil
return c, err
}
func (wd *BrowserWebDriver) ClosePage(pageIndex int) (err error) {
@ -362,8 +355,7 @@ func (wd *BrowserWebDriver) httpRequest(method string, rawURL string, rawBody []
return nil, err
}
rawResp, err := io.ReadAll(resp.Body)
rawResp, _ := io.ReadAll(resp.Body)
if resp.StatusCode != http.StatusOK {
return nil, errors.New(resp.Status)
}

View File

@ -10,12 +10,14 @@ type TapRequest struct {
Duration float64 `json:"duration"`
Options *option.ActionOptions `json:"options,omitempty"`
}
type uploadRequest struct {
X float64 `json:"x"`
Y float64 `json:"y"`
FileUrl string `json:"file_url"`
FileFormat string `json:"file_format"`
}
type DragRequest struct {
FromX float64 `json:"from_x" binding:"required"`
FromY float64 `json:"from_y" binding:"required"`