mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-10 23:12:41 +08:00
Merge branch 'fix-report' into 'master'
fix: ai_assert screenshot See merge request iesqa/httprunner!125
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0-250710
|
v5.0.0-250711
|
||||||
|
|||||||
207
report.go
207
report.go
@@ -1194,6 +1194,15 @@ const htmlTemplate = `<!DOCTYPE html>
|
|||||||
padding: 12px;
|
padding: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.screenshot-display .screenshot-image {
|
||||||
|
min-height: 300px;
|
||||||
|
padding: 15px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.screenshot-display .screenshot-image img {
|
||||||
|
max-height: 350px;
|
||||||
|
}
|
||||||
|
|
||||||
.screenshot-item-compact {
|
.screenshot-item-compact {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
@@ -1212,7 +1221,7 @@ const htmlTemplate = `<!DOCTYPE html>
|
|||||||
.screenshot-item-compact .screenshot-image img {
|
.screenshot-item-compact .screenshot-image img {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: auto;
|
height: auto;
|
||||||
max-height: 500px;
|
max-height: 350px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: transform 0.2s;
|
transition: transform 0.2s;
|
||||||
@@ -1223,7 +1232,7 @@ const htmlTemplate = `<!DOCTYPE html>
|
|||||||
|
|
||||||
/* Handle very tall screenshots */
|
/* Handle very tall screenshots */
|
||||||
.screenshot-item-compact .screenshot-image img[style*="height"] {
|
.screenshot-item-compact .screenshot-image img[style*="height"] {
|
||||||
max-height: 400px;
|
max-height: 350px;
|
||||||
width: auto;
|
width: auto;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
@@ -1838,101 +1847,6 @@ const htmlTemplate = `<!DOCTYPE html>
|
|||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* AI Assertion Styles */
|
|
||||||
.ai-assertion-section {
|
|
||||||
margin-top: 15px;
|
|
||||||
padding: 15px;
|
|
||||||
background: linear-gradient(135deg, #f0f8ff 0%, #f5f5ff 100%);
|
|
||||||
border: 2px solid #4169e1;
|
|
||||||
border-radius: 12px;
|
|
||||||
box-shadow: 0 4px 8px rgba(65, 105, 225, 0.15);
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-assertion-section h5 {
|
|
||||||
margin: 0 0 15px 0;
|
|
||||||
color: #4169e1;
|
|
||||||
font-size: 1.1em;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-screenshot-container {
|
|
||||||
background: white;
|
|
||||||
border: 1px solid #dee2e6;
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 12px;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-screenshot {
|
|
||||||
text-align: center;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-screenshot img {
|
|
||||||
max-width: 100%;
|
|
||||||
height: auto;
|
|
||||||
border-radius: 8px;
|
|
||||||
border: 1px solid #dee2e6;
|
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
||||||
cursor: pointer;
|
|
||||||
transition: transform 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-screenshot img:hover {
|
|
||||||
transform: scale(1.02);
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-analysis-container {
|
|
||||||
background: white;
|
|
||||||
border: 1px solid #dee2e6;
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 12px;
|
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-analysis-content {
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-thought {
|
|
||||||
background: linear-gradient(135deg, #e8f4fd 0%, #f0f8ff 100%);
|
|
||||||
border: 1px solid #4169e1;
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 12px;
|
|
||||||
margin: 10px 0;
|
|
||||||
color: #2c3e50;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-thought .thought-content {
|
|
||||||
margin-top: 8px;
|
|
||||||
font-style: italic;
|
|
||||||
color: #34495e;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
word-wrap: break-word;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-raw-response {
|
|
||||||
background: #f8f9fa;
|
|
||||||
border: 1px solid #dee2e6;
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 12px;
|
|
||||||
margin: 10px 0;
|
|
||||||
color: #2c3e50;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-raw-response .response-content {
|
|
||||||
margin-top: 8px;
|
|
||||||
font-family: monospace;
|
|
||||||
font-size: 0.9em;
|
|
||||||
background: white;
|
|
||||||
padding: 8px;
|
|
||||||
border-radius: 4px;
|
|
||||||
border: 1px solid #e9ecef;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
word-wrap: break-word;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 768px) {
|
@media screen and (max-width: 768px) {
|
||||||
.validator-ai-layout {
|
.validator-ai-layout {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -2891,10 +2805,8 @@ const htmlTemplate = `<!DOCTYPE html>
|
|||||||
<div class="screenshot-display">
|
<div class="screenshot-display">
|
||||||
{{$base64Image := encodeImageBase64 $action.AIResult.ImagePath}}
|
{{$base64Image := encodeImageBase64 $action.AIResult.ImagePath}}
|
||||||
{{if $base64Image}}
|
{{if $base64Image}}
|
||||||
<div class="screenshot-item-compact">
|
<div class="screenshot-image">
|
||||||
<div class="screenshot-image">
|
<img src="data:image/jpeg;base64,{{$base64Image}}" alt="AI {{title $action.AIResult.Type}} Screenshot" onclick="openImageModal(this.src)" />
|
||||||
<img src="data:image/jpeg;base64,{{$base64Image}}" alt="AI {{title $action.AIResult.Type}} Screenshot" onclick="openImageModal(this.src)" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
@@ -3048,53 +2960,60 @@ const htmlTemplate = `<!DOCTYPE html>
|
|||||||
|
|
||||||
<!-- AI Assertion Results -->
|
<!-- AI Assertion Results -->
|
||||||
{{if $validator.ai_result}}
|
{{if $validator.ai_result}}
|
||||||
<div class="ai-assertion-section">
|
<div class="validator-ai-content">
|
||||||
<h5>🤖 AI Assertion Details</h5>
|
<!-- Display AI Thought -->
|
||||||
|
{{if $validator.ai_result.assertion_result.thought}}
|
||||||
<!-- AI Assertion Screenshot -->
|
<div class="thought">{{$validator.ai_result.assertion_result.thought}}</div>
|
||||||
{{if $validator.ai_result.image_path}}
|
|
||||||
<div class="ai-screenshot-container">
|
|
||||||
<span class="step-name">📸 AI Assertion Screenshot</span>
|
|
||||||
{{if $validator.ai_result.screenshot_elapsed}}
|
|
||||||
<span class="duration">{{formatDuration $validator.ai_result.screenshot_elapsed}}</span>
|
|
||||||
{{end}}
|
|
||||||
<div class="ai-screenshot">
|
|
||||||
{{$base64Image := encodeImageBase64 $validator.ai_result.image_path}}
|
|
||||||
{{if $base64Image}}
|
|
||||||
<img src="data:image/jpeg;base64,{{$base64Image}}" alt="AI Assertion Screenshot" onclick="openImageModal(this.src)" />
|
|
||||||
{{end}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
<!-- AI Model Analysis -->
|
<!-- AI Assertion Layout: Screenshot left, Analysis right -->
|
||||||
<div class="ai-analysis-container">
|
<div class="validator-ai-layout">
|
||||||
<span class="step-name">🧠 AI Model Analysis</span>
|
<!-- Left column: Screenshot -->
|
||||||
{{if $validator.ai_result.model_call_elapsed}}
|
{{if $validator.ai_result.image_path}}
|
||||||
<span class="duration">{{formatDuration $validator.ai_result.model_call_elapsed}}</span>
|
<div class="validator-column-screenshot">
|
||||||
|
<div class="validator-step-compact">
|
||||||
|
<div class="step-header-compact">
|
||||||
|
<span class="step-name">📸 AI Assertion Screenshot</span>
|
||||||
|
{{if $validator.ai_result.screenshot_elapsed}}
|
||||||
|
<span class="duration">{{formatDuration $validator.ai_result.screenshot_elapsed}}</span>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
<div class="screenshot-display">
|
||||||
|
{{$base64Image := encodeImageBase64 $validator.ai_result.image_path}}
|
||||||
|
{{if $base64Image}}
|
||||||
|
<div class="screenshot-image">
|
||||||
|
<img src="data:image/jpeg;base64,{{$base64Image}}" alt="AI Assertion Screenshot" onclick="openImageModal(this.src)" />
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
<div class="ai-analysis-content">
|
|
||||||
{{if $validator.ai_result.assertion_result.model_name}}
|
<!-- Right column: AI Analysis -->
|
||||||
<div class="model-info">🤖 Model: {{$validator.ai_result.assertion_result.model_name}}</div>
|
<div class="validator-column-analysis">
|
||||||
{{end}}
|
<div class="validator-step-compact">
|
||||||
{{if $validator.ai_result.assertion_result.usage}}
|
<div class="step-header-compact">
|
||||||
<div class="usage-info">📊 Tokens: {{$validator.ai_result.assertion_result.usage.PromptTokens}} in / {{$validator.ai_result.assertion_result.usage.CompletionTokens}} out / {{$validator.ai_result.assertion_result.usage.TotalTokens}} total</div>
|
<span class="step-name">🤖 AI Assertion Analysis</span>
|
||||||
{{end}}
|
{{if $validator.ai_result.model_call_elapsed}}
|
||||||
{{if $validator.ai_result.resolution}}
|
<span class="duration">{{formatDuration $validator.ai_result.model_call_elapsed}}</span>
|
||||||
<div class="model-info">📐 Resolution: {{$validator.ai_result.resolution.Width}}x{{$validator.ai_result.resolution.Height}}</div>
|
{{end}}
|
||||||
{{end}}
|
</div>
|
||||||
{{if $validator.ai_result.assertion_result.thought}}
|
<div class="validator-ai-details">
|
||||||
<div class="ai-thought">
|
{{if $validator.ai_result.assertion_result.model_name}}
|
||||||
<strong>💭 AI Reasoning:</strong>
|
<div class="model-info">🤖 Model: {{$validator.ai_result.assertion_result.model_name}}</div>
|
||||||
<div class="thought-content">{{$validator.ai_result.assertion_result.thought}}</div>
|
{{end}}
|
||||||
|
{{if $validator.ai_result.assertion_result.usage}}
|
||||||
|
<div class="usage-info">📊 Tokens: {{$validator.ai_result.assertion_result.usage.PromptTokens}} in / {{$validator.ai_result.assertion_result.usage.CompletionTokens}} out / {{$validator.ai_result.assertion_result.usage.TotalTokens}} total</div>
|
||||||
|
{{end}}
|
||||||
|
{{if $validator.ai_result.resolution}}
|
||||||
|
<div class="model-info">📐 Resolution: {{$validator.ai_result.resolution.Width}}x{{$validator.ai_result.resolution.Height}}</div>
|
||||||
|
{{end}}
|
||||||
|
{{if $validator.ai_result.assertion_result.content}}
|
||||||
|
<div class="model-info">💬 Assertion Result: {{$validator.ai_result.assertion_result.content}}</div>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
|
||||||
{{if $validator.ai_result.assertion_result.content}}
|
|
||||||
<div class="ai-raw-response">
|
|
||||||
<strong>📝 Raw Model Response:</strong>
|
|
||||||
<div class="response-content">{{$validator.ai_result.assertion_result.content}}</div>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
29
uixt/sdk.go
29
uixt/sdk.go
@@ -156,9 +156,13 @@ func (dExt *XTDriver) ExecuteAction(ctx context.Context, action option.MobileAct
|
|||||||
// For regular actions, collect session data and return it directly
|
// For regular actions, collect session data and return it directly
|
||||||
sessionData := dExt.GetSession().GetData(true) // reset after getting data
|
sessionData := dExt.GetSession().GetData(true) // reset after getting data
|
||||||
|
|
||||||
log.Debug().Str("tool", string(tool.Name())).
|
// Log execution result, but avoid printing base64 data for screenshot tools
|
||||||
Interface("result", result.Content).
|
logger := log.Debug().Str("tool", string(tool.Name()))
|
||||||
Msg("executed action via MCP tool")
|
if tool.Name() != option.ACTION_ScreenShot {
|
||||||
|
logger.Interface("result", result.Content)
|
||||||
|
}
|
||||||
|
logger.Msg("executed action via MCP tool")
|
||||||
|
|
||||||
return sessionData, nil
|
return sessionData, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,22 +245,27 @@ func (dExt *XTDriver) CallMCPTool(ctx context.Context,
|
|||||||
log.Debug().Err(err).
|
log.Debug().Err(err).
|
||||||
Str("server", serverName).
|
Str("server", serverName).
|
||||||
Str("tool", toolName).
|
Str("tool", toolName).
|
||||||
Msg("MCP hook call failed")
|
Msg("call MCP tool failed")
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if result.IsError {
|
if result.IsError {
|
||||||
log.Debug().
|
logger := log.Debug().
|
||||||
Str("server", serverName).
|
Str("server", serverName).
|
||||||
Str("tool", toolName).
|
Str("tool", toolName)
|
||||||
Interface("content", result.Content).
|
|
||||||
Msg("MCP hook returned error")
|
// Avoid printing base64 data for screenshot tools
|
||||||
return nil, fmt.Errorf("MCP hook returned error")
|
if toolName != string(option.ACTION_ScreenShot) {
|
||||||
|
logger.Interface("content", result.Content)
|
||||||
|
}
|
||||||
|
logger.Msg("call MCP tool failed")
|
||||||
|
|
||||||
|
return nil, fmt.Errorf("call MCP tool %s failed", toolName)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug().
|
log.Debug().
|
||||||
Str("server", serverName).
|
Str("server", serverName).
|
||||||
Str("tool", toolName).
|
Str("tool", toolName).
|
||||||
Msg("MCP hook called successfully")
|
Msg("call MCP tool successfully")
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user