mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-11 18:11:21 +08:00
38 lines
995 B
Go
38 lines
995 B
Go
package option
|
|
|
|
func NewBrowserDeviceOptions(opts ...BrowserDeviceOption) *BrowserDeviceOptions {
|
|
config := &BrowserDeviceOptions{}
|
|
for _, opt := range opts {
|
|
opt(config)
|
|
}
|
|
return config
|
|
}
|
|
|
|
type BrowserDeviceOptions struct {
|
|
BrowserID string `json:"browser_id,omitempty" yaml:"browser_id,omitempty"`
|
|
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
|
|
Width int `json:"width,omitempty" yaml:"width,omitempty"`
|
|
Height int `json:"height,omitempty" yaml:"height,omitempty"`
|
|
}
|
|
|
|
type BrowserDeviceOption func(*BrowserDeviceOptions)
|
|
|
|
func WithBrowserID(serial string) BrowserDeviceOption {
|
|
return func(device *BrowserDeviceOptions) {
|
|
device.BrowserID = serial
|
|
}
|
|
}
|
|
|
|
func WithBrowserLogOn(logOn bool) BrowserDeviceOption {
|
|
return func(device *BrowserDeviceOptions) {
|
|
device.LogOn = logOn
|
|
}
|
|
}
|
|
|
|
func WithBrowserPageSize(width, height int) BrowserDeviceOption {
|
|
return func(device *BrowserDeviceOptions) {
|
|
device.Width = width
|
|
device.Height = height
|
|
}
|
|
}
|