mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-06 20:32:44 +08:00
feat: add auto popup handler configuration for HRPRunner
This commit is contained in:
@@ -36,6 +36,7 @@ var (
|
|||||||
genHTMLReport bool
|
genHTMLReport bool
|
||||||
caseTimeout float32
|
caseTimeout float32
|
||||||
runMCPConfigPath string // MCP config path for run command
|
runMCPConfigPath string // MCP config path for run command
|
||||||
|
autoPopupHandler bool // enable auto popup handler for all steps
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -48,6 +49,7 @@ func init() {
|
|||||||
CmdRun.Flags().BoolVarP(&genHTMLReport, "gen-html-report", "g", false, "generate html report")
|
CmdRun.Flags().BoolVarP(&genHTMLReport, "gen-html-report", "g", false, "generate html report")
|
||||||
CmdRun.Flags().Float32Var(&caseTimeout, "case-timeout", 3600, "set testcase timeout (seconds)")
|
CmdRun.Flags().Float32Var(&caseTimeout, "case-timeout", 3600, "set testcase timeout (seconds)")
|
||||||
CmdRun.Flags().StringVar(&runMCPConfigPath, "mcp-config", "", "path to the MCP config file")
|
CmdRun.Flags().StringVar(&runMCPConfigPath, "mcp-config", "", "path to the MCP config file")
|
||||||
|
CmdRun.Flags().BoolVar(&autoPopupHandler, "enable-auto-popup-handler", false, "enable auto popup handler for all UI steps")
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeHRPRunner() *hrp.HRPRunner {
|
func makeHRPRunner() *hrp.HRPRunner {
|
||||||
@@ -76,5 +78,8 @@ func makeHRPRunner() *hrp.HRPRunner {
|
|||||||
if runMCPConfigPath != "" {
|
if runMCPConfigPath != "" {
|
||||||
runner.SetMCPConfigPath(runMCPConfigPath)
|
runner.SetMCPConfigPath(runMCPConfigPath)
|
||||||
}
|
}
|
||||||
|
if autoPopupHandler {
|
||||||
|
runner.EnableAutoPopupHandler(autoPopupHandler)
|
||||||
|
}
|
||||||
return runner
|
return runner
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,4 +63,4 @@ Copyright © 2017-present debugtalk. Apache-2.0 License.
|
|||||||
* [hrp startproject](hrp_startproject.md) - Create a scaffold project
|
* [hrp startproject](hrp_startproject.md) - Create a scaffold project
|
||||||
* [hrp wiki](hrp_wiki.md) - visit https://httprunner.com
|
* [hrp wiki](hrp_wiki.md) - visit https://httprunner.com
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -23,4 +23,4 @@ simple utils for android device management
|
|||||||
* [hrp adb install](hrp_adb_install.md) - push package to the device and install them automatically
|
* [hrp adb install](hrp_adb_install.md) - push package to the device and install them automatically
|
||||||
* [hrp adb screencap](hrp_adb_screencap.md) - Start android screen capture
|
* [hrp adb screencap](hrp_adb_screencap.md) - Start android screen capture
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -24,4 +24,4 @@ hrp adb devices [flags]
|
|||||||
|
|
||||||
* [hrp adb](hrp_adb.md) - simple utils for android device management
|
* [hrp adb](hrp_adb.md) - simple utils for android device management
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -28,4 +28,4 @@ hrp adb install [flags] PACKAGE
|
|||||||
|
|
||||||
* [hrp adb](hrp_adb.md) - simple utils for android device management
|
* [hrp adb](hrp_adb.md) - simple utils for android device management
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -25,4 +25,4 @@ hrp adb screencap [flags]
|
|||||||
|
|
||||||
* [hrp adb](hrp_adb.md) - simple utils for android device management
|
* [hrp adb](hrp_adb.md) - simple utils for android device management
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -36,4 +36,4 @@ hrp build $path ... [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -34,4 +34,4 @@ hrp convert $path... [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -29,4 +29,4 @@ simple utils for ios device management
|
|||||||
* [hrp ios uninstall](hrp_ios_uninstall.md) - uninstall package automatically
|
* [hrp ios uninstall](hrp_ios_uninstall.md) - uninstall package automatically
|
||||||
* [hrp ios xctest](hrp_ios_xctest.md) - run xctest
|
* [hrp ios xctest](hrp_ios_xctest.md) - run xctest
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -26,4 +26,4 @@ hrp ios apps [flags]
|
|||||||
|
|
||||||
* [hrp ios](hrp_ios.md) - simple utils for ios device management
|
* [hrp ios](hrp_ios.md) - simple utils for ios device management
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -24,4 +24,4 @@ hrp ios devices [flags]
|
|||||||
|
|
||||||
* [hrp ios](hrp_ios.md) - simple utils for ios device management
|
* [hrp ios](hrp_ios.md) - simple utils for ios device management
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -25,4 +25,4 @@ hrp ios install [flags] PACKAGE
|
|||||||
|
|
||||||
* [hrp ios](hrp_ios.md) - simple utils for ios device management
|
* [hrp ios](hrp_ios.md) - simple utils for ios device management
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -28,4 +28,4 @@ hrp ios mount [flags]
|
|||||||
|
|
||||||
* [hrp ios](hrp_ios.md) - simple utils for ios device management
|
* [hrp ios](hrp_ios.md) - simple utils for ios device management
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -26,4 +26,4 @@ hrp ios ps [flags]
|
|||||||
|
|
||||||
* [hrp ios](hrp_ios.md) - simple utils for ios device management
|
* [hrp ios](hrp_ios.md) - simple utils for ios device management
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -25,4 +25,4 @@ hrp ios reboot [flags]
|
|||||||
|
|
||||||
* [hrp ios](hrp_ios.md) - simple utils for ios device management
|
* [hrp ios](hrp_ios.md) - simple utils for ios device management
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -24,4 +24,4 @@ hrp ios tunnel [flags]
|
|||||||
|
|
||||||
* [hrp ios](hrp_ios.md) - simple utils for ios device management
|
* [hrp ios](hrp_ios.md) - simple utils for ios device management
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -26,4 +26,4 @@ hrp ios uninstall [flags] PACKAGE
|
|||||||
|
|
||||||
* [hrp ios](hrp_ios.md) - simple utils for ios device management
|
* [hrp ios](hrp_ios.md) - simple utils for ios device management
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -28,4 +28,4 @@ hrp ios xctest [flags]
|
|||||||
|
|
||||||
* [hrp ios](hrp_ios.md) - simple utils for ios device management
|
* [hrp ios](hrp_ios.md) - simple utils for ios device management
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -28,4 +28,4 @@ hrp mcp-server [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -31,4 +31,4 @@ hrp mcphost [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -24,4 +24,4 @@ hrp pytest $path ... [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -33,4 +33,4 @@ hrp report [result_folder] [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -21,16 +21,17 @@ hrp run $path... [flags]
|
|||||||
### Options
|
### Options
|
||||||
|
|
||||||
```
|
```
|
||||||
--case-timeout float32 set testcase timeout (seconds) (default 3600)
|
--case-timeout float32 set testcase timeout (seconds) (default 3600)
|
||||||
-c, --continue-on-failure continue running next step when failure occurs
|
-c, --continue-on-failure continue running next step when failure occurs
|
||||||
-g, --gen-html-report generate html report
|
--enable-auto-popup-handler enable auto popup handler for all UI steps
|
||||||
-h, --help help for run
|
-g, --gen-html-report generate html report
|
||||||
--http-stat turn on HTTP latency stat (DNSLookup, TCP Connection, etc.)
|
-h, --help help for run
|
||||||
--log-plugin turn on plugin logging
|
--http-stat turn on HTTP latency stat (DNSLookup, TCP Connection, etc.)
|
||||||
--log-requests-off turn off request & response details logging
|
--log-plugin turn on plugin logging
|
||||||
--mcp-config string path to the MCP config file
|
--log-requests-off turn off request & response details logging
|
||||||
-p, --proxy-url string set proxy url
|
--mcp-config string path to the MCP config file
|
||||||
-s, --save-tests save tests summary
|
-p, --proxy-url string set proxy url
|
||||||
|
-s, --save-tests save tests summary
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
@@ -45,4 +46,4 @@ hrp run $path... [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -30,4 +30,4 @@ hrp server start [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -29,4 +29,4 @@ hrp startproject $project_name [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
@@ -24,4 +24,4 @@ hrp wiki [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
* [hrp](hrp.md) - All-in-One Testing Framework for API, UI and Performance
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 8-Jun-2025
|
###### Auto generated by spf13/cobra on 27-Jun-2025
|
||||||
|
|||||||
26
runner.go
26
runner.go
@@ -18,12 +18,12 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
|
"github.com/httprunner/funplugin"
|
||||||
"github.com/jinzhu/copier"
|
"github.com/jinzhu/copier"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"golang.org/x/net/http2"
|
"golang.org/x/net/http2"
|
||||||
|
|
||||||
"github.com/httprunner/funplugin"
|
|
||||||
"github.com/httprunner/httprunner/v5/code"
|
"github.com/httprunner/httprunner/v5/code"
|
||||||
"github.com/httprunner/httprunner/v5/internal/builtin"
|
"github.com/httprunner/httprunner/v5/internal/builtin"
|
||||||
"github.com/httprunner/httprunner/v5/internal/config"
|
"github.com/httprunner/httprunner/v5/internal/config"
|
||||||
@@ -50,10 +50,11 @@ func NewRunner(t *testing.T) *HRPRunner {
|
|||||||
interruptSignal := make(chan os.Signal, 1)
|
interruptSignal := make(chan os.Signal, 1)
|
||||||
signal.Notify(interruptSignal, syscall.SIGTERM, syscall.SIGINT)
|
signal.Notify(interruptSignal, syscall.SIGTERM, syscall.SIGINT)
|
||||||
return &HRPRunner{
|
return &HRPRunner{
|
||||||
t: t,
|
t: t,
|
||||||
failfast: true, // default to failfast
|
failfast: true, // default to failfast
|
||||||
genHTMLReport: false,
|
genHTMLReport: false,
|
||||||
mcpConfigPath: "",
|
mcpConfigPath: "",
|
||||||
|
autoPopupHandler: false,
|
||||||
httpClient: &http.Client{
|
httpClient: &http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||||
@@ -87,6 +88,7 @@ type HRPRunner struct {
|
|||||||
saveTests bool
|
saveTests bool
|
||||||
genHTMLReport bool
|
genHTMLReport bool
|
||||||
mcpConfigPath string // MCP config file path
|
mcpConfigPath string // MCP config file path
|
||||||
|
autoPopupHandler bool // enable auto popup handler for all UI steps
|
||||||
httpClient *http.Client
|
httpClient *http.Client
|
||||||
http2Client *http.Client
|
http2Client *http.Client
|
||||||
wsDialer *websocket.Dialer
|
wsDialer *websocket.Dialer
|
||||||
@@ -198,6 +200,13 @@ func (r *HRPRunner) GenHTMLReport() *HRPRunner {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EnableAutoPopupHandler configures whether to enable auto popup handler for all UI steps.
|
||||||
|
func (r *HRPRunner) EnableAutoPopupHandler(enabled bool) *HRPRunner {
|
||||||
|
log.Info().Bool("autoPopupHandler", enabled).Msg("[init] EnableAutoPopupHandler")
|
||||||
|
r.autoPopupHandler = enabled
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
// SetMCPConfigPath configures the MCP config path.
|
// SetMCPConfigPath configures the MCP config path.
|
||||||
func (r *HRPRunner) SetMCPConfigPath(mcpConfigPath string) *HRPRunner {
|
func (r *HRPRunner) SetMCPConfigPath(mcpConfigPath string) *HRPRunner {
|
||||||
log.Info().Str("mcpConfigPath", mcpConfigPath).Msg("[init] SetMCPConfigPath")
|
log.Info().Str("mcpConfigPath", mcpConfigPath).Msg("[init] SetMCPConfigPath")
|
||||||
@@ -394,6 +403,13 @@ func NewCaseRunner(testcase TestCase, hrpRunner *HRPRunner) (*CaseRunner, error)
|
|||||||
return nil, errors.Wrap(err, "parse testcase config failed")
|
return nil, errors.Wrap(err, "parse testcase config failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// apply global auto popup handler setting if enabled
|
||||||
|
// priority: command line > testcase config > step config
|
||||||
|
if hrpRunner.autoPopupHandler {
|
||||||
|
parsedConfig.AutoPopupHandler = true
|
||||||
|
log.Info().Bool("autoPopupHandler", true).Msg("applied global auto popup handler setting")
|
||||||
|
}
|
||||||
|
|
||||||
// set request timeout in seconds
|
// set request timeout in seconds
|
||||||
if parsedConfig.RequestTimeout != 0 {
|
if parsedConfig.RequestTimeout != 0 {
|
||||||
hrpRunner.SetRequestTimeout(parsedConfig.RequestTimeout)
|
hrpRunner.SetRequestTimeout(parsedConfig.RequestTimeout)
|
||||||
|
|||||||
Reference in New Issue
Block a user