mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-26 01:51:29 +08:00
fix: merge
This commit is contained in:
@@ -42,7 +42,7 @@ func (dev *BrowserDevice) UUID() string {
|
||||
}
|
||||
|
||||
func (dev *BrowserDevice) Setup() error {
|
||||
return errors.New("not support")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dev *BrowserDevice) LogEnabled() bool {
|
||||
@@ -50,7 +50,7 @@ func (dev *BrowserDevice) LogEnabled() bool {
|
||||
}
|
||||
|
||||
func (dev *BrowserDevice) Teardown() error {
|
||||
return errors.New("not support")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dev *BrowserDevice) Install(appPath string, opts ...option.InstallOption) error {
|
||||
|
||||
@@ -553,7 +553,7 @@ func (wd *BrowserWebDriver) Clear(packageName string) error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
func (wd *BrowserWebDriver) Setup() error {
|
||||
return errors.New("not support")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) GetDevice() IDevice {
|
||||
@@ -622,7 +622,7 @@ func (wd *BrowserWebDriver) RecordScreen(folderPath string, duration time.Durati
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) TearDown() error {
|
||||
return errors.New("not support")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) InitSession(capabilities option.Capabilities) error {
|
||||
|
||||
@@ -421,21 +421,6 @@ func (wd *BrowserWebDriver) LoginNoneUI(packageName, phoneNumber string, captcha
|
||||
return loginSuccss, err
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) Status() (deviceStatus types.DeviceStatus, err error) {
|
||||
log.Warn().Msg("Status not implemented in ADBDriver")
|
||||
return
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) DeviceInfo() (deviceInfo types.DeviceInfo, err error) {
|
||||
log.Warn().Msg("DeviceInfo not implemented in ADBDriver")
|
||||
return
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) BatteryInfo() (batteryInfo types.BatteryInfo, err error) {
|
||||
log.Warn().Msg("BatteryInfo not implemented in ADBDriver")
|
||||
return
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) WindowSize() (types.Size, error) {
|
||||
resp, err := wd.httpGet(http.MethodGet, wd.sessionId, "window_size")
|
||||
if err != nil {
|
||||
@@ -450,63 +435,6 @@ func (wd *BrowserWebDriver) WindowSize() (types.Size, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) Screen() (uixt.Screen, error) {
|
||||
return uixt.Screen{}, errors.New("not support")
|
||||
}
|
||||
func (wd *BrowserWebDriver) Scale() (float64, error) {
|
||||
return 0, errors.New("not support")
|
||||
}
|
||||
|
||||
// GetTimestamp returns the timestamp of the mobile device
|
||||
func (wd *BrowserWebDriver) GetTimestamp() (timestamp int64, err error) {
|
||||
return 0, errors.New("not support")
|
||||
}
|
||||
|
||||
// Homescreen Forces the device under test to switch to the home screen
|
||||
func (wd *BrowserWebDriver) Homescreen() error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) Unlock() (err error) {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
// AppTerminate Terminate an application with the given package name.
|
||||
// Either `true` if the app has been successfully terminated or `false` if it was not running
|
||||
func (wd *BrowserWebDriver) AppTerminate(packageName string) (bool, error) {
|
||||
return false, errors.New("not support")
|
||||
}
|
||||
|
||||
// AssertForegroundApp returns nil if the given package and activity are in foreground
|
||||
func (wd *BrowserWebDriver) AssertForegroundApp(packageName string, activityType ...string) error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) Back() error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) AppClear(packageName string) error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
func (wd *BrowserWebDriver) ClearImages() error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) PushImage(localPath string) error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) Orientation() (orientation types.Orientation, err error) {
|
||||
log.Warn().Msg("Orientation not implemented in ADBDriver")
|
||||
return
|
||||
}
|
||||
|
||||
// Tap Sends a tap event at the coordinate.
|
||||
func (wd *BrowserWebDriver) Tap(x, y int, options ...option.ActionOption) error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) TapFloat(x, y float64, options ...option.ActionOption) error {
|
||||
actionOptions := option.NewActionOptions(options...)
|
||||
duration := 0.1
|
||||
@@ -541,138 +469,3 @@ func (wd *BrowserWebDriver) UploadFile(x, y float64, FileUrl, FileFormat string)
|
||||
_, err = wd.httpPOST(data, wd.sessionId, "ui/upload")
|
||||
return err
|
||||
}
|
||||
|
||||
// TouchAndHold Initiates a long-press gesture at the coordinate, holding for the specified duration.
|
||||
//
|
||||
// second: The default value is 1
|
||||
func (wd *BrowserWebDriver) TouchAndHold(x, y float64, options ...option.ActionOption) error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
// Swipe works like Drag, but `pressForDuration` value is 0
|
||||
func (wd *BrowserWebDriver) Swipe(fromX, fromY, toX, toY float64, options ...option.ActionOption) error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) SwipeFloat(fromX, fromY, toX, toY float64, options ...option.ActionOption) error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) SetIme(ime string) error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
// SendKeys Types a string into active element. There must be element with keyboard focus,
|
||||
// otherwise an error is raised.
|
||||
// WithFrequency option can be used to set frequency of typing (letters per sec). The default value is 60
|
||||
func (wd *BrowserWebDriver) SendKeys(text string, options ...option.ActionOption) error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) Clear(packageName string) error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
func (wd *BrowserWebDriver) Setup() error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) GetDevice() uixt.IDevice {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) ForegroundInfo() (app types.AppInfo, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// PressBack Presses the back button
|
||||
func (wd *BrowserWebDriver) PressBack(options ...option.ActionOption) error {
|
||||
_, err := wd.httpPOST(map[string]interface{}{}, wd.sessionId, "ui/back")
|
||||
return err
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) PressKeyCode(keyCode uixt.KeyCode) (err error) {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) Backspace(count int, options ...option.ActionOption) (err error) {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) LogoutNoneUI(packageName string) error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) TapByText(text string, options ...option.ActionOption) error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
// AccessibleSource Return application elements accessibility tree
|
||||
func (wd *BrowserWebDriver) AccessibleSource() (string, error) {
|
||||
return "", errors.New("not support")
|
||||
}
|
||||
|
||||
// HealthCheck Health check might modify simulator state so it should only be called in-between testing sessions
|
||||
//
|
||||
// Checks health of XCTest by:
|
||||
// 1) Querying application for some elements,
|
||||
// 2) Triggering some device events.
|
||||
func (wd *BrowserWebDriver) HealthCheck() error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
func (wd *BrowserWebDriver) GetAppiumSettings() (map[string]interface{}, error) {
|
||||
return nil, errors.New("not support")
|
||||
}
|
||||
func (wd *BrowserWebDriver) SetAppiumSettings(settings map[string]interface{}) (map[string]interface{}, error) {
|
||||
return nil, errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) IsHealthy() (bool, error) {
|
||||
return false, errors.New("not support")
|
||||
}
|
||||
|
||||
// triggers the log capture and returns the log entries
|
||||
func (wd *BrowserWebDriver) StartCaptureLog(identifier ...string) (err error) {
|
||||
return errors.New("not support")
|
||||
}
|
||||
func (wd *BrowserWebDriver) StopCaptureLog() (result interface{}, err error) {
|
||||
return nil, errors.New("not support")
|
||||
}
|
||||
func (wd *BrowserWebDriver) RecordScreen(folderPath string, duration time.Duration) (videoPath string, err error) {
|
||||
return "", errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) TearDown() error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) InitSession(capabilities option.Capabilities) error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) GetSession() *uixt.DriverSession {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) ScreenRecord(duration time.Duration) (videoPath string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) Rotation() (rotation types.Rotation, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) SetRotation(rotation types.Rotation) error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) Home() error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) TapXY(x, y float64, opts ...option.ActionOption) error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
func (wd *BrowserWebDriver) TapAbsXY(x, y float64, opts ...option.ActionOption) error {
|
||||
return errors.New("not support")
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ func createBrowserHandler(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
func deleteBrowserHandler(c *gin.Context) {
|
||||
driver, err := GetDriver(c)
|
||||
func (r *Router) deleteBrowserHandler(c *gin.Context) {
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
RenderError(c, err)
|
||||
return
|
||||
@@ -117,7 +117,6 @@ func deleteBrowserHandler(c *gin.Context) {
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
func pushImageHandler(c *gin.Context) {
|
||||
func (r *Router) pushImageHandler(c *gin.Context) {
|
||||
var pushMediaReq PushMediaRequest
|
||||
if err := c.ShouldBindJSON(&pushMediaReq); err != nil {
|
||||
|
||||
@@ -33,23 +33,23 @@ type IRouterBaseMethod interface {
|
||||
|
||||
func (r *Router) Init() {
|
||||
r.Engine.Use(teardown())
|
||||
r.Engine.GET("/ping", pingHandler)
|
||||
r.Engine.GET("/", pingHandler)
|
||||
r.Engine.POST("/", pingHandler)
|
||||
r.Engine.GET("/api/v1/devices", listDeviceHandler)
|
||||
r.Engine.GET("/ping", r.pingHandler)
|
||||
r.Engine.GET("/", r.pingHandler)
|
||||
r.Engine.POST("/", r.pingHandler)
|
||||
r.Engine.GET("/api/v1/devices", r.listDeviceHandler)
|
||||
r.Engine.POST("/api/v1/browser/create_browser", createBrowserHandler)
|
||||
|
||||
apiV1PlatformSerial := r.Group("/api/v1").Group("/:platform").Group("/:serial")
|
||||
|
||||
// UI operations
|
||||
apiV1PlatformSerial.POST("/ui/tap", tapHandler)
|
||||
apiV1PlatformSerial.POST("/ui/double_tap", doubleTapHandler)
|
||||
apiV1PlatformSerial.POST("/ui/drag", dragHandler)
|
||||
apiV1PlatformSerial.POST("/ui/input", inputHandler)
|
||||
apiV1PlatformSerial.POST("/ui/home", homeHandler)
|
||||
apiV1PlatformSerial.POST("/ui/upload", uploadHandler)
|
||||
apiV1PlatformSerial.POST("/ui/hover", hoverHandler)
|
||||
apiV1PlatformSerial.POST("/ui/scroll", scrollHandler)
|
||||
apiV1PlatformSerial.POST("/ui/tap", r.tapHandler)
|
||||
apiV1PlatformSerial.POST("/ui/double_tap", r.doubleTapHandler)
|
||||
apiV1PlatformSerial.POST("/ui/drag", r.dragHandler)
|
||||
apiV1PlatformSerial.POST("/ui/input", r.inputHandler)
|
||||
apiV1PlatformSerial.POST("/ui/home", r.homeHandler)
|
||||
apiV1PlatformSerial.POST("/ui/upload", r.uploadHandler)
|
||||
apiV1PlatformSerial.POST("/ui/hover", r.hoverHandler)
|
||||
apiV1PlatformSerial.POST("/ui/scroll", r.scrollHandler)
|
||||
|
||||
// Key operations
|
||||
apiV1PlatformSerial.POST("/key/unlock", r.unlockHandler)
|
||||
@@ -66,12 +66,12 @@ func (r *Router) Init() {
|
||||
apiV1PlatformSerial.POST("/app/uninstall", r.uninstallAppHandler)
|
||||
|
||||
// Device operations
|
||||
apiV1PlatformSerial.GET("/screenshot", screenshotHandler)
|
||||
apiV1PlatformSerial.DELETE("/close_browser", deleteBrowserHandler)
|
||||
apiV1PlatformSerial.GET("/video", videoHandler)
|
||||
apiV1PlatformSerial.POST("/device/push_image", pushImageHandler)
|
||||
apiV1PlatformSerial.POST("/device/clear_image", clearImageHandler)
|
||||
apiV1PlatformSerial.GET("/adb/source", adbSourceHandler)
|
||||
apiV1PlatformSerial.GET("/screenshot", r.screenshotHandler)
|
||||
apiV1PlatformSerial.DELETE("/close_browser", r.deleteBrowserHandler)
|
||||
apiV1PlatformSerial.GET("/video", r.videoHandler)
|
||||
apiV1PlatformSerial.POST("/device/push_image", r.pushImageHandler)
|
||||
apiV1PlatformSerial.POST("/device/clear_image", r.clearImageHandler)
|
||||
apiV1PlatformSerial.GET("/adb/source", r.adbSourceHandler)
|
||||
|
||||
// uixt operations
|
||||
apiV1PlatformSerial.POST("/uixt/action", r.uixtActionHandler)
|
||||
|
||||
18
server/ui.go
18
server/ui.go
@@ -30,39 +30,39 @@ func (r *Router) tapHandler(c *gin.Context) {
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
func uploadHandler(c *gin.Context) {
|
||||
func (r *Router) uploadHandler(c *gin.Context) {
|
||||
var uploadRequest uploadRequest
|
||||
if err := c.ShouldBindJSON(&uploadRequest); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
RenderError(c, err)
|
||||
return
|
||||
}
|
||||
err = driver.IDriver.(*uixt.BrowserWebDriver).UploadFile(uploadRequest.X, uploadRequest.Y, uploadRequest.FileUrl, uploadRequest.FileFormat)
|
||||
err = driver.GetIDriver().(*uixt.BrowserWebDriver).UploadFile(uploadRequest.X, uploadRequest.Y, uploadRequest.FileUrl, uploadRequest.FileFormat)
|
||||
if err != nil {
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
func hoverHandler(c *gin.Context) {
|
||||
func (r *Router) hoverHandler(c *gin.Context) {
|
||||
var hoverReq HoverRequest
|
||||
if err := c.ShouldBindJSON(&hoverReq); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
RenderError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err = driver.IDriver.(*uixt.BrowserWebDriver).Hover(hoverReq.X, hoverReq.Y)
|
||||
err = driver.GetIDriver().(*uixt.BrowserWebDriver).Hover(hoverReq.X, hoverReq.Y)
|
||||
|
||||
if err != nil {
|
||||
RenderError(c, err)
|
||||
@@ -71,20 +71,20 @@ func hoverHandler(c *gin.Context) {
|
||||
RenderSuccess(c, true)
|
||||
}
|
||||
|
||||
func scrollHandler(c *gin.Context) {
|
||||
func (r *Router) scrollHandler(c *gin.Context) {
|
||||
var scrollReq ScrollRequest
|
||||
if err := c.ShouldBindJSON(&scrollReq); err != nil {
|
||||
RenderErrorValidateRequest(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
driver, err := GetDriver(c)
|
||||
driver, err := r.GetDriver(c)
|
||||
if err != nil {
|
||||
RenderError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err = driver.IDriver.(*uixt.BrowserWebDriver).Scroll(scrollReq.Delta)
|
||||
err = driver.GetIDriver().(*uixt.BrowserWebDriver).Scroll(scrollReq.Delta)
|
||||
|
||||
if err != nil {
|
||||
RenderError(c, err)
|
||||
|
||||
Reference in New Issue
Block a user