mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-11 10:49:43 +08:00
fix: web ui test
This commit is contained in:
71
step_ui.go
71
step_ui.go
@@ -28,8 +28,8 @@ type StepMobile struct {
|
||||
Android *MobileUI `json:"android,omitempty" yaml:"android,omitempty"`
|
||||
Harmony *MobileUI `json:"harmony,omitempty" yaml:"harmony,omitempty"`
|
||||
IOS *MobileUI `json:"ios,omitempty" yaml:"ios,omitempty"`
|
||||
|
||||
cache *MobileUI // used for caching
|
||||
Browser *MobileUI `json:"browser,omitempty" yaml:"browser,omitempty"`
|
||||
cache *MobileUI // used for caching
|
||||
}
|
||||
|
||||
// uniform interface for all types of mobile systems
|
||||
@@ -50,6 +50,10 @@ func (s *StepMobile) obj() *MobileUI {
|
||||
s.cache = s.Android
|
||||
s.cache.OSType = string(StepTypeAndroid)
|
||||
return s.cache
|
||||
} else if s.Browser != nil {
|
||||
s.cache = s.Browser
|
||||
s.cache.OSType = string(stepTypeBrowser)
|
||||
return s.cache
|
||||
} else if s.Mobile != nil {
|
||||
s.cache = s.Mobile
|
||||
return s.cache
|
||||
@@ -79,6 +83,14 @@ func (s *StepMobile) InstallApp(path string) *StepMobile {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *StepMobile) LoginNoneUI(packageName, phoneNumber string, captcha, password string) *StepMobile {
|
||||
s.obj().Actions = append(s.obj().Actions, uixt.MobileAction{
|
||||
Method: uixt.ACTION_LoginNoneUI,
|
||||
Params: []string{packageName, phoneNumber, captcha, password},
|
||||
})
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *StepMobile) AppLaunch(bundleId string) *StepMobile {
|
||||
s.obj().Actions = append(s.obj().Actions, uixt.MobileAction{
|
||||
Method: uixt.ACTION_AppLaunch,
|
||||
@@ -286,6 +298,61 @@ func (s *StepMobile) SwipeToTapTexts(texts interface{}, opts ...option.ActionOpt
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *StepMobile) RightClick(x, y float64, options ...option.ActionOption) *StepMobile {
|
||||
action := uixt.MobileAction{
|
||||
Method: uixt.ACTION_RightClick,
|
||||
Params: []float64{x, y},
|
||||
Options: option.NewActionOptions(options...),
|
||||
}
|
||||
s.obj().Actions = append(s.obj().Actions, action)
|
||||
return s
|
||||
}
|
||||
func (s *StepMobile) RightClickBySelector(selector string, options ...option.ActionOption) *StepMobile {
|
||||
action := uixt.MobileAction{
|
||||
Method: uixt.ACTION_RightClickBySelector,
|
||||
Params: selector,
|
||||
Options: option.NewActionOptions(options...),
|
||||
}
|
||||
s.obj().Actions = append(s.obj().Actions, action)
|
||||
return s
|
||||
}
|
||||
func (s *StepMobile) HoverBySelector(selector string, options ...option.ActionOption) *StepMobile {
|
||||
action := uixt.MobileAction{
|
||||
Method: uixt.ACTION_HoverBySelector,
|
||||
Params: selector,
|
||||
Options: option.NewActionOptions(options...),
|
||||
}
|
||||
s.obj().Actions = append(s.obj().Actions, action)
|
||||
return s
|
||||
}
|
||||
func (s *StepMobile) TapBySelector(selector string, options ...option.ActionOption) *StepMobile {
|
||||
action := uixt.MobileAction{
|
||||
Method: uixt.ACTION_TapBySelector,
|
||||
Params: selector,
|
||||
Options: option.NewActionOptions(options...),
|
||||
}
|
||||
s.obj().Actions = append(s.obj().Actions, action)
|
||||
return s
|
||||
}
|
||||
func (s *StepMobile) ClosePage(idx int, options ...option.ActionOption) *StepMobile {
|
||||
action := uixt.MobileAction{
|
||||
Method: uixt.ACTION_ClosePage,
|
||||
Params: idx,
|
||||
Options: option.NewActionOptions(options...),
|
||||
}
|
||||
s.obj().Actions = append(s.obj().Actions, action)
|
||||
return s
|
||||
}
|
||||
func (s *StepMobile) GetElementTextBySelector(selector string, options ...option.ActionOption) *StepMobile {
|
||||
action := uixt.MobileAction{
|
||||
Method: uixt.ACTION_GetElementTextBySelector,
|
||||
Params: selector,
|
||||
Options: option.NewActionOptions(options...),
|
||||
}
|
||||
s.obj().Actions = append(s.obj().Actions, action)
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *StepMobile) Input(text string, opts ...option.ActionOption) *StepMobile {
|
||||
action := uixt.MobileAction{
|
||||
Method: uixt.ACTION_Input,
|
||||
|
||||
Reference in New Issue
Block a user