Skip to content

Commit b686a5d

Browse files
minor update
1 parent 06f6826 commit b686a5d

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

webqa_agent/testers/case_gen/graph.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,12 @@ async def execute_single_case(state: MainGraphState) -> dict:
495495
ui_tester_instance = state["ui_tester_instance"]
496496
case_name = case.get("name")
497497

498+
# Set test context for context-aware verification
499+
ui_tester_instance.current_test_objective = case.get("objective", case.get("name"))
500+
ui_tester_instance.current_success_criteria = case.get("success_criteria", [])
501+
# Clear old execution history to avoid cross-case pollution
502+
ui_tester_instance.execution_history.clear()
503+
498504
language = state.get('language', 'zh-CN')
499505
logging.debug(f"Execute case language: {language}")
500506
default_text = '智能功能测试' if language == 'zh-CN' else 'AI Function Test'

webqa_agent/testers/case_gen/tools/element_action_tool.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,19 @@ async def _arun(self, assertion: str) -> str:
446446
# Build execution context from instance state (context-aware verification)
447447
execution_context = None
448448
if self.ui_tester_instance.last_action_context:
449+
# Build complete execution context with all 5 expected fields
449450
execution_context = {
450451
"last_action": self.ui_tester_instance.last_action_context,
451452
"test_objective": self.ui_tester_instance.current_test_objective,
453+
"success_criteria": self.ui_tester_instance.current_success_criteria,
454+
"completed_steps": [
455+
h for h in self.ui_tester_instance.execution_history
456+
if h.get("success") is True # Use strict comparison to avoid None misclassification
457+
],
458+
"failed_steps": [
459+
h for h in self.ui_tester_instance.execution_history
460+
if h.get("success") is False # Use strict comparison to avoid None misclassification
461+
]
452462
}
453463
logging.debug("Passing execution context to verify()")
454464

webqa_agent/testers/function_tester.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def __init__(self, llm_config: Dict[str, Any], browser_session: BrowserSession =
4747
self.last_action_context: Optional[Dict[str, Any]] = None
4848
self.execution_history: List[Dict[str, Any]] = []
4949
self.current_test_objective: Optional[str] = None
50+
self.current_success_criteria: List[str] = [] # Store test success criteria
5051

5152
async def initialize(self, browser_session: BrowserSession = None):
5253
if browser_session:
@@ -207,6 +208,15 @@ async def action(self, test_step: str, file_path: str = None) -> Tuple[Dict[str,
207208
# Automatically store step data
208209
self.add_step_data(execution_steps_dict, step_type="action")
209210

211+
# Update execution history for context-aware verification
212+
self.execution_history.append({
213+
"description": test_step,
214+
"success": execution_result.get("success"),
215+
"timestamp": end_time,
216+
"dom_diff": diff_elems,
217+
"actions": execution_steps
218+
})
219+
210220
return execution_steps_dict, execution_result
211221

212222
except Exception as e:
@@ -233,6 +243,14 @@ async def action(self, test_step: str, file_path: str = None) -> Tuple[Dict[str,
233243
"end_time": end_time,
234244
}
235245

246+
self.execution_history.append({
247+
"description": test_step,
248+
"success": False,
249+
"timestamp": end_time,
250+
"dom_diff": {},
251+
"actions": []
252+
})
253+
236254
# Automatically store error step data
237255
self.add_step_data(error_execution_steps, step_type="action")
238256

0 commit comments

Comments
 (0)