fix: rename browser_web_driver to browser_driver
This commit is contained in:
parent
720e5fa504
commit
69d06a7215
|
@ -1 +1 @@
|
||||||
v5.0.0+2503032117
|
v5.0.0+2503032127
|
||||||
|
|
|
@ -2,16 +2,19 @@ package uixt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
|
|
||||||
"github.com/httprunner/httprunner/v5/pkg/uixt/types"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
|
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
|
||||||
|
"github.com/httprunner/httprunner/v5/pkg/uixt/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BrowserDevice struct {
|
type BrowserDevice struct {
|
||||||
BrowserId string `json:"browser_id,omitempty" yaml:"browser_id,omitempty"`
|
BrowserId string `json:"browser_id,omitempty" yaml:"browser_id,omitempty"`
|
||||||
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
|
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BrowserDeviceOption func(*BrowserDevice)
|
type BrowserDeviceOption func(*BrowserDevice)
|
||||||
|
|
||||||
func WithBrowserId(serial string) BrowserDeviceOption {
|
func WithBrowserId(serial string) BrowserDeviceOption {
|
||||||
|
|
|
@ -12,10 +12,11 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"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/pkg/errors"
|
||||||
"github.com/rs/zerolog/log"
|
"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"
|
const BROWSER_LOCAL_ADDRESS = "localhost:8093"
|
||||||
|
@ -71,8 +72,7 @@ func CreateBrowser(timeout int) (browserInfo *BrowserInfo, err error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
rawResp, err := io.ReadAll(resp.Body)
|
rawResp, _ := io.ReadAll(resp.Body)
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return nil, errors.New(resp.Status)
|
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.Host = BROWSER_LOCAL_ADDRESS
|
||||||
driver.urlPrefix.Scheme = "http"
|
driver.urlPrefix.Scheme = "http"
|
||||||
driver.scale = 1.0
|
driver.scale = 1.0
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "create browser session failed")
|
|
||||||
}
|
|
||||||
driver.sessionId = browserId
|
driver.sessionId = browserId
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("adb forward: %w", err)
|
|
||||||
}
|
|
||||||
return driver, nil
|
return driver, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,8 +142,7 @@ func (wd *BrowserWebDriver) DeleteSession() (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
rawResp, err := io.ReadAll(resp.Body)
|
rawResp, _ := io.ReadAll(resp.Body)
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return errors.New(resp.Status)
|
return errors.New(resp.Status)
|
||||||
}
|
}
|
||||||
|
@ -185,7 +178,7 @@ func (wd *BrowserWebDriver) CreateNetListener() (*websocket.Conn, error) {
|
||||||
"context_id":"%v"
|
"context_id":"%v"
|
||||||
}`, wd.sessionId)
|
}`, wd.sessionId)
|
||||||
err = c.WriteMessage(websocket.TextMessage, []byte(initMessage))
|
err = c.WriteMessage(websocket.TextMessage, []byte(initMessage))
|
||||||
return c, nil
|
return c, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wd *BrowserWebDriver) ClosePage(pageIndex int) (err error) {
|
func (wd *BrowserWebDriver) ClosePage(pageIndex int) (err error) {
|
||||||
|
@ -362,8 +355,7 @@ func (wd *BrowserWebDriver) httpRequest(method string, rawURL string, rawBody []
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
rawResp, err := io.ReadAll(resp.Body)
|
rawResp, _ := io.ReadAll(resp.Body)
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return nil, errors.New(resp.Status)
|
return nil, errors.New(resp.Status)
|
||||||
}
|
}
|
|
@ -10,12 +10,14 @@ type TapRequest struct {
|
||||||
Duration float64 `json:"duration"`
|
Duration float64 `json:"duration"`
|
||||||
Options *option.ActionOptions `json:"options,omitempty"`
|
Options *option.ActionOptions `json:"options,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type uploadRequest struct {
|
type uploadRequest struct {
|
||||||
X float64 `json:"x"`
|
X float64 `json:"x"`
|
||||||
Y float64 `json:"y"`
|
Y float64 `json:"y"`
|
||||||
FileUrl string `json:"file_url"`
|
FileUrl string `json:"file_url"`
|
||||||
FileFormat string `json:"file_format"`
|
FileFormat string `json:"file_format"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DragRequest struct {
|
type DragRequest struct {
|
||||||
FromX float64 `json:"from_x" binding:"required"`
|
FromX float64 `json:"from_x" binding:"required"`
|
||||||
FromY float64 `json:"from_y" binding:"required"`
|
FromY float64 `json:"from_y" binding:"required"`
|
||||||
|
|
Loading…
Reference in New Issue