mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-09 01:17:30 +08:00
fix: default input frequency from 60 to 10
feat: swipe and tap by /action without duration
This commit is contained in:
@@ -297,7 +297,7 @@ func (o *ActionOptions) updateData(data map[string]interface{}) {
|
|||||||
data["frequency"] = o.Frequency
|
data["frequency"] = o.Frequency
|
||||||
}
|
}
|
||||||
if _, ok := data["frequency"]; !ok {
|
if _, ok := data["frequency"]; !ok {
|
||||||
data["frequency"] = 60 // default frequency
|
data["frequency"] = 10 // default frequency
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := data["replace"]; !ok {
|
if _, ok := data["replace"]; !ok {
|
||||||
|
|||||||
@@ -283,14 +283,26 @@ func (ud *uiaDriver) TapFloat(x, y float64, options ...ActionOption) (err error)
|
|||||||
y += actionOptions.getRandomOffset()
|
y += actionOptions.getRandomOffset()
|
||||||
|
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"x": x,
|
"actions": []interface{}{
|
||||||
"y": y,
|
map[string]interface{}{
|
||||||
|
"type": "pointer",
|
||||||
|
"parameters": map[string]string{"pointerType": "touch"},
|
||||||
|
"id": "touch",
|
||||||
|
"actions": []interface{}{
|
||||||
|
map[string]interface{}{"type": "pointerMove", "duration": 0, "x": x, "y": y, "origin": "viewport"},
|
||||||
|
map[string]interface{}{"type": "pointerDown", "duration": 0, "button": 0},
|
||||||
|
map[string]interface{}{"type": "pause", "duration": 100},
|
||||||
|
map[string]interface{}{"type": "pointerUp", "duration": 0, "button": 0},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// update data options in post data for extra uiautomator configurations
|
// update data options in post data for extra uiautomator configurations
|
||||||
actionOptions.updateData(data)
|
actionOptions.updateData(data)
|
||||||
|
|
||||||
_, err = ud.httpPOST(data, "/session", ud.sessionId, "appium/tap")
|
_, err = ud.httpPOST(data, "/session", ud.sessionId, "actions/tap")
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ud *uiaDriver) TouchAndHold(x, y int, second ...float64) (err error) {
|
func (ud *uiaDriver) TouchAndHold(x, y int, second ...float64) (err error) {
|
||||||
@@ -361,28 +373,27 @@ func (ud *uiaDriver) Swipe(fromX, fromY, toX, toY int, options ...ActionOption)
|
|||||||
func (ud *uiaDriver) SwipeFloat(fromX, fromY, toX, toY float64, options ...ActionOption) error {
|
func (ud *uiaDriver) SwipeFloat(fromX, fromY, toX, toY float64, options ...ActionOption) error {
|
||||||
// register(postHandler, new Swipe("/wd/hub/session/:sessionId/touch/perform"))
|
// register(postHandler, new Swipe("/wd/hub/session/:sessionId/touch/perform"))
|
||||||
actionOptions := NewActionOptions(options...)
|
actionOptions := NewActionOptions(options...)
|
||||||
if len(actionOptions.Offset) == 4 {
|
|
||||||
fromX += float64(actionOptions.Offset[0])
|
|
||||||
fromY += float64(actionOptions.Offset[1])
|
|
||||||
toX += float64(actionOptions.Offset[2])
|
|
||||||
toY += float64(actionOptions.Offset[3])
|
|
||||||
}
|
|
||||||
fromX += actionOptions.getRandomOffset()
|
|
||||||
fromY += actionOptions.getRandomOffset()
|
|
||||||
toX += actionOptions.getRandomOffset()
|
|
||||||
toY += actionOptions.getRandomOffset()
|
|
||||||
|
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"startX": fromX,
|
"actions": []interface{}{
|
||||||
"startY": fromY,
|
map[string]interface{}{
|
||||||
"endX": toX,
|
"type": "pointer",
|
||||||
"endY": toY,
|
"parameters": map[string]string{"pointerType": "touch"},
|
||||||
|
"id": "touch",
|
||||||
|
"actions": []interface{}{
|
||||||
|
map[string]interface{}{"type": "pointerMove", "duration": 0, "x": fromX, "y": fromY, "origin": "viewport"},
|
||||||
|
map[string]interface{}{"type": "pointerDown", "duration": 0, "button": 0},
|
||||||
|
map[string]interface{}{"type": "pointerMove", "duration": 200, "x": toX, "y": toY, "origin": "viewport"},
|
||||||
|
map[string]interface{}{"type": "pointerUp", "duration": 0, "button": 0},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// update data options in post data for extra uiautomator configurations
|
// update data options in post data for extra uiautomator configurations
|
||||||
actionOptions.updateData(data)
|
actionOptions.updateData(data)
|
||||||
|
|
||||||
_, err := ud.httpPOST(data, "/session", ud.sessionId, "touch/perform")
|
_, err := ud.httpPOST(data, "/session", ud.sessionId, "actions/swipe")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user