mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
feat: describe screenshot file name with params
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0+2411132058
|
v5.0.0+2411132151
|
||||||
|
|||||||
+10
-4
@@ -2,6 +2,7 @@ package uixt
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
_ "image/gif"
|
_ "image/gif"
|
||||||
_ "image/png"
|
_ "image/png"
|
||||||
|
|
||||||
@@ -53,19 +54,24 @@ func newDriverExt(device IDevice, driver IWebDriver, options ...DriverOption) (d
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (dExt *DriverExt) AssertOCR(text, assert string) bool {
|
func (dExt *DriverExt) AssertOCR(text, assert string) bool {
|
||||||
|
var options []ActionOption
|
||||||
|
options = append(options, WithScreenShotFileName(fmt.Sprintf("assert_ocr_%s", text)))
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
switch assert {
|
switch assert {
|
||||||
case AssertionEqual:
|
case AssertionEqual:
|
||||||
_, err = dExt.FindScreenText(text)
|
_, err = dExt.FindScreenText(text, options...)
|
||||||
return err == nil
|
return err == nil
|
||||||
case AssertionNotEqual:
|
case AssertionNotEqual:
|
||||||
_, err = dExt.FindScreenText(text)
|
_, err = dExt.FindScreenText(text, options...)
|
||||||
return err != nil
|
return err != nil
|
||||||
case AssertionExists:
|
case AssertionExists:
|
||||||
_, err = dExt.FindScreenText(text, WithRegex(true))
|
options = append(options, WithRegex(true))
|
||||||
|
_, err = dExt.FindScreenText(text, options...)
|
||||||
return err == nil
|
return err == nil
|
||||||
case AssertionNotExists:
|
case AssertionNotExists:
|
||||||
_, err = dExt.FindScreenText(text, WithRegex(true))
|
options = append(options, WithRegex(true))
|
||||||
|
_, err = dExt.FindScreenText(text, options...)
|
||||||
return err != nil
|
return err != nil
|
||||||
default:
|
default:
|
||||||
log.Warn().Str("assert method", assert).Msg("unexpected assert method")
|
log.Warn().Str("assert method", assert).Msg("unexpected assert method")
|
||||||
|
|||||||
@@ -126,11 +126,13 @@ func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *S
|
|||||||
return screenResult, nil
|
return screenResult, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dExt *DriverExt) GetScreenTexts() (ocrTexts OCRTexts, err error) {
|
func (dExt *DriverExt) GetScreenTexts(options ...ActionOption) (ocrTexts OCRTexts, err error) {
|
||||||
screenResult, err := dExt.GetScreenResult(
|
actionOptions := NewActionOptions(options...)
|
||||||
WithScreenShotOCR(true), WithScreenShotUpload(true),
|
if actionOptions.ScreenShotFileName == "" {
|
||||||
WithScreenShotFileName("get_screen_texts"),
|
options = append(options, WithScreenShotFileName("get_screen_texts"))
|
||||||
)
|
}
|
||||||
|
options = append(options, WithScreenShotOCR(true), WithScreenShotUpload(true))
|
||||||
|
screenResult, err := dExt.GetScreenResult(options...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -148,7 +150,11 @@ func (dExt *DriverExt) FindUIRectInUIKit(search string, options ...ActionOption)
|
|||||||
}
|
}
|
||||||
|
|
||||||
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()
|
actionOptions := NewActionOptions(options...)
|
||||||
|
if actionOptions.ScreenShotFileName == "" {
|
||||||
|
options = append(options, WithScreenShotFileName(fmt.Sprintf("find_screen_text_%s", text)))
|
||||||
|
}
|
||||||
|
ocrTexts, err := dExt.GetScreenTexts(options...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -166,8 +172,11 @@ func (dExt *DriverExt) FindScreenText(text string, options ...ActionOption) (poi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (dExt *DriverExt) FindUIResult(options ...ActionOption) (point PointF, err error) {
|
func (dExt *DriverExt) FindUIResult(options ...ActionOption) (point PointF, err error) {
|
||||||
options = append(options, WithScreenShotFileName("find_ui_result"))
|
|
||||||
actionOptions := NewActionOptions(options...)
|
actionOptions := NewActionOptions(options...)
|
||||||
|
if actionOptions.ScreenShotFileName == "" {
|
||||||
|
options = append(options, WithScreenShotFileName(
|
||||||
|
fmt.Sprintf("find_ui_result_%s", strings.Join(actionOptions.ScreenShotWithUITypes, "_"))))
|
||||||
|
}
|
||||||
|
|
||||||
screenResult, err := dExt.GetScreenResult(options...)
|
screenResult, err := dExt.GetScreenResult(options...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ func (dExt *DriverExt) TapXY(x, y float64, options ...ActionOption) error {
|
|||||||
|
|
||||||
func (dExt *DriverExt) TapByOCR(ocrText string, options ...ActionOption) error {
|
func (dExt *DriverExt) TapByOCR(ocrText string, options ...ActionOption) error {
|
||||||
actionOptions := NewActionOptions(options...)
|
actionOptions := NewActionOptions(options...)
|
||||||
|
if actionOptions.ScreenShotFileName == "" {
|
||||||
|
options = append(options, WithScreenShotFileName(fmt.Sprintf("tap_by_ocr_%s", ocrText)))
|
||||||
|
}
|
||||||
|
|
||||||
point, err := dExt.FindScreenText(ocrText, options...)
|
point, err := dExt.FindScreenText(ocrText, options...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user