modify resetUIA2Driver and uia2HttpRequest

This commit is contained in:
buyuxiang
2023-07-20 19:57:18 +08:00
parent 135e24d378
commit 9482887ab3

View File

@@ -93,14 +93,14 @@ func (wd *Driver) httpRequest(method string, rawURL string, rawBody []byte) (raw
return return
} }
func (wd *Driver) resetUIA2Driver() (string, error) { func (wd *Driver) resetUIA2Driver() error {
ud, err := NewUIADriver(NewCapabilities(), wd.urlPrefix.String()) ud, err := NewUIADriver(NewCapabilities(), wd.urlPrefix.String())
if err != nil { if err != nil {
return "", err return err
} }
wd.client = ud.client wd.client = ud.client
wd.sessionId = ud.sessionId wd.sessionId = ud.sessionId
return ud.sessionId, nil return nil
} }
func (wd *Driver) uia2HttpRequest(method string, rawURL string, rawBody []byte, disableRetry ...bool) (rawResp rawResponse, err error) { func (wd *Driver) uia2HttpRequest(method string, rawURL string, rawBody []byte, disableRetry ...bool) (rawResp rawResponse, err error) {
@@ -112,13 +112,12 @@ func (wd *Driver) uia2HttpRequest(method string, rawURL string, rawBody []byte,
} }
// wait for UIA2 server to resume automatically // wait for UIA2 server to resume automatically
time.Sleep(3 * time.Second) time.Sleep(3 * time.Second)
var oldSessionID, newSessionID string oldSessionID := wd.sessionId
oldSessionID = wd.sessionId if err = wd.resetUIA2Driver(); err != nil {
if newSessionID, err = wd.resetUIA2Driver(); err != nil { log.Err(err).Msgf("failed to reset uia2 driver, retry count: %v", retryCount)
log.Err(err).Msgf("failed to reset uia2 session, retry count: %v", retryCount)
continue continue
} }
log.Debug().Str("new session", newSessionID).Str("old session", oldSessionID).Msgf("successful to reset uia2 session, retry count: %v", retryCount) log.Debug().Str("new session", wd.sessionId).Str("old session", oldSessionID).Msgf("successful to reset uia2 driver, retry count: %v", retryCount)
if oldSessionID != "" { if oldSessionID != "" {
rawURL = strings.Replace(rawURL, oldSessionID, wd.sessionId, 1) rawURL = strings.Replace(rawURL, oldSessionID, wd.sessionId, 1)
} }