mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-31 21:39:41 +08:00
feat: add option WithScreenShot
This commit is contained in:
@@ -784,6 +784,7 @@ type DataOptions struct {
|
||||
IgnoreNotFoundError bool // ignore error if target element not found
|
||||
MaxRetryTimes int // max retry times if target element not found
|
||||
Interval float64 // interval between retries in seconds
|
||||
ScreenShotFilename string // turn on screenshot and specify file name
|
||||
}
|
||||
|
||||
type DataOption func(data *DataOptions)
|
||||
@@ -860,6 +861,16 @@ func WithDataWaitTime(sec float64) DataOption {
|
||||
}
|
||||
}
|
||||
|
||||
func WithScreenShot(fileName ...string) DataOption {
|
||||
return func(data *DataOptions) {
|
||||
if len(fileName) > 0 {
|
||||
data.ScreenShotFilename = fileName[0]
|
||||
} else {
|
||||
data.ScreenShotFilename = fmt.Sprintf("screenshot_%d", time.Now().Unix())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func NewDataOptions(options ...DataOption) *DataOptions {
|
||||
dataOptions := &DataOptions{}
|
||||
for _, option := range options {
|
||||
|
||||
Reference in New Issue
Block a user