fix: panic by nil pointer

This commit is contained in:
lilong.129
2024-09-12 11:12:05 +08:00
parent 6f6cefe4bc
commit a87a4ea680
4 changed files with 20 additions and 6 deletions

View File

@@ -11,7 +11,10 @@ import (
func (dExt *DriverExt) TapAbsXY(x, y float64, options ...ActionOption) error {
// tap on absolute coordinate [x, y]
err := dExt.Driver.TapFloat(x, y, options...)
return errors.Wrap(code.MobileUITapError, err.Error())
if err != nil {
return errors.Wrap(code.MobileUITapError, err.Error())
}
return nil
}
func (dExt *DriverExt) TapXY(x, y float64, options ...ActionOption) error {
@@ -88,7 +91,10 @@ func (dExt *DriverExt) DoubleTapXY(x, y float64, options ...ActionOption) error
x = x * float64(windowSize.Width)
y = y * float64(windowSize.Height)
err = dExt.Driver.DoubleTapFloat(x, y, options...)
return errors.Wrap(code.MobileUITapError, err.Error())
if err != nil {
return errors.Wrap(code.MobileUITapError, err.Error())
}
return nil
}
func (dExt *DriverExt) DoubleTap(param string, options ...ActionOption) (err error) {
@@ -102,5 +108,8 @@ func (dExt *DriverExt) DoubleTapOffset(param string, xOffset, yOffset float64, o
}
err = dExt.Driver.DoubleTapFloat(point.X+xOffset, point.Y+yOffset, options...)
return errors.Wrap(code.MobileUITapError, err.Error())
if err != nil {
return errors.Wrap(code.MobileUITapError, err.Error())
}
return nil
}