mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-12 16:01:27 +08:00
feat: click on xpath
This commit is contained in:
@@ -315,8 +315,15 @@ func (w *wdaClient) doAction(action MobileAction) error {
|
|||||||
return w.Driver.Tap(location[0], location[1])
|
return w.Driver.Tap(location[0], location[1])
|
||||||
}
|
}
|
||||||
// click on xpath
|
// click on xpath
|
||||||
if _, ok := action.Params.(string); ok {
|
if xpath, ok := action.Params.(string); ok {
|
||||||
return errActionNotImplemented
|
selector := gwda.BySelector{
|
||||||
|
XPath: xpath,
|
||||||
|
}
|
||||||
|
ele, err := w.Driver.FindElement(selector)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "failed to find element")
|
||||||
|
}
|
||||||
|
return ele.Click()
|
||||||
}
|
}
|
||||||
return fmt.Errorf("invalid click params: %v", action.Params)
|
return fmt.Errorf("invalid click params: %v", action.Params)
|
||||||
case uiDoubleClick:
|
case uiDoubleClick:
|
||||||
@@ -346,6 +353,8 @@ func (w *wdaClient) doAction(action MobileAction) error {
|
|||||||
return fmt.Errorf("invalid swipe params: %v", params)
|
return fmt.Errorf("invalid swipe params: %v", params)
|
||||||
}
|
}
|
||||||
fromX, fromY, toX, toY = params[0], params[1], params[2], params[3]
|
fromX, fromY, toX, toY = params[0], params[1], params[2], params[3]
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("invalid swipe params: %v", action.Params)
|
||||||
}
|
}
|
||||||
return w.Driver.Swipe(fromX, fromY, toX, toY)
|
return w.Driver.Swipe(fromX, fromY, toX, toY)
|
||||||
case uiInput:
|
case uiInput:
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func TestIOSAction(t *testing.T) {
|
|||||||
Config: NewConfig("ios ui action"),
|
Config: NewConfig("ios ui action"),
|
||||||
TestSteps: []IStep{
|
TestSteps: []IStep{
|
||||||
NewStep("launch douyin").
|
NewStep("launch douyin").
|
||||||
IOS().Click("抖音").
|
IOS().Click("//*[@label='抖音']").
|
||||||
Validate().
|
Validate().
|
||||||
AssertTextExists("首页", "首页 tab 不存在").
|
AssertTextExists("首页", "首页 tab 不存在").
|
||||||
AssertTextExists("消息", "消息 tab 不存在"),
|
AssertTextExists("消息", "消息 tab 不存在"),
|
||||||
@@ -40,8 +40,6 @@ func TestIOSAction(t *testing.T) {
|
|||||||
IOS().SwipeUp().SwipeUp().SwipeDown(),
|
IOS().SwipeUp().SwipeUp().SwipeDown(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
tCase := testCase.ToTCase()
|
|
||||||
fmt.Println(tCase)
|
|
||||||
|
|
||||||
err := NewRunner(t).Run(testCase)
|
err := NewRunner(t).Run(testCase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user