mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-07 23:41:22 +08:00
change: remove duplicate code
This commit is contained in:
@@ -104,23 +104,6 @@ func (dExt *DriverExt) GetStepCacheData() map[string]interface{} {
|
|||||||
return cacheData
|
return cacheData
|
||||||
}
|
}
|
||||||
|
|
||||||
// isPathExists returns true if path exists, whether path is file or dir
|
|
||||||
func isPathExists(path string) bool {
|
|
||||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dExt *DriverExt) FindUIRectInUIKit(search string, options ...ActionOption) (point PointF, err error) {
|
|
||||||
// click on text, using OCR
|
|
||||||
if !isPathExists(search) {
|
|
||||||
return dExt.FindScreenText(search, options...)
|
|
||||||
}
|
|
||||||
err = errors.New("ocr text not found")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dExt *DriverExt) AssertOCR(text, assert string) bool {
|
func (dExt *DriverExt) AssertOCR(text, assert string) bool {
|
||||||
var err error
|
var err error
|
||||||
switch assert {
|
switch assert {
|
||||||
|
|||||||
@@ -108,6 +108,15 @@ func (dExt *DriverExt) GetScreenTexts() (ocrTexts OCRTexts, err error) {
|
|||||||
return screenResult.Texts, nil
|
return screenResult.Texts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dExt *DriverExt) FindUIRectInUIKit(search string, options ...ActionOption) (point PointF, err error) {
|
||||||
|
// click on text, using OCR
|
||||||
|
if !builtin.IsPathExists(search) {
|
||||||
|
return dExt.FindScreenText(search, options...)
|
||||||
|
}
|
||||||
|
err = errors.New("ocr text not found")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (dExt *DriverExt) FindScreenText(text string, options ...ActionOption) (point PointF, err error) {
|
func (dExt *DriverExt) FindScreenText(text string, options ...ActionOption) (point PointF, err error) {
|
||||||
ocrTexts, err := dExt.GetScreenTexts()
|
ocrTexts, err := dExt.GetScreenTexts()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user