Skip to content

Commit a734ae2

Browse files
rollback
1 parent 539cc60 commit a734ae2

File tree

3 files changed

+4
-200
lines changed

3 files changed

+4
-200
lines changed

webqa_agent/llm/prompt.py

Lines changed: 3 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -83,44 +83,13 @@ class LLMPrompt:
8383
- All plans must reflect actual context in screenshot.
8484
- Always output strict **valid JSON**. No comments or markdown.
8585
86-
## Navigation Strategy Guidelines (CRITICAL)
87-
88-
### Action Selection Priority for Navigation
89-
When planning navigation actions, follow this STRICT priority order:
90-
91-
1. **GoToPage (HIGHEST RELIABILITY - PREFERRED)**
92-
- Use when: Target URL is known or can be determined
93-
- Best for: Returning to original tabs/pages, switching between known pages, going to homepage
94-
- Reliability: 100% - Direct URL manipulation, no UI dependency
95-
- Example: Returning to original tab with known URL
96-
97-
2. **GoBack (HIGH RELIABILITY)**
98-
- Use when: Browser history navigation is appropriate
99-
- Best for: Sequential backward navigation
100-
- Reliability: 95% - Browser-native functionality
101-
- Example: Returning to previous form after submission
102-
103-
3. **Tap/Click (LOWER RELIABILITY - USE WITH CAUTION)**
104-
- Use when: Target URL is unknown AND element interaction is required
105-
- Best for: Discovering new pages, triggering dynamic content
106-
- Reliability: 60-80% - Depends on element state, page load, icon behavior
107-
- Example: Clicking unexplored menu items
108-
109-
### Critical Decision Rule
110-
**IF you know the target URL → ALWAYS use GoToPage over Tap**
111-
- This includes: returning to original tab, going to homepage, switching between tabs
112-
- Rationale: URL navigation is deterministic, UI element clicks are probabilistic
113-
11486
## Actions
11587
11688
Each action includes `type` and `param`, optionally with `locate`.
11789
11890
Each action has a
119-
- type: 'Tap', tap the located element [USE ONLY WHEN URL UNKNOWN]
91+
- type: 'Tap', tap the located element
12092
* {{ locate: {{ id: string }}, param: null }}
121-
* WARNING: Less reliable for navigation - UI elements may fail or behave inconsistently
122-
* Use ONLY when: target URL is unknown AND you need to discover new pages
123-
* Do NOT use for: returning to known pages, switching tabs when URLs are available
12493
- type: 'Hover', move mouse over to the located element
12594
* {{ locate: {{ id: string }}, param: null }}
12695
- type: 'Input', replace the value in the input field
@@ -147,12 +116,9 @@ class LLMPrompt:
147116
- type: 'GetNewPage', get the new page
148117
* {{ param: null }}
149118
* use this action when the instruction is a "get new page" statement or "open in new tab" or "open in new window".
150-
- type: 'GoToPage', navigate directly to a specific URL [PREFERRED FOR RELIABLE NAVIGATION]
119+
- type: 'GoToPage', navigate directly to a specific URL
151120
* {{ param: {{ url: string }} }}
152-
* CRITICAL: This is the MOST RELIABLE navigation method - use whenever target URL is known
153-
* PREFERRED for: returning to original tab/page, switching between known pages, going to homepage
154-
* AVOID clicking UI elements (logos, icons) for navigation when URL is available
155-
* Example: To return to original tab, use GoToPage with the original URL instead of clicking browser tabs or page icons
121+
* use this action when you need to navigate to a specific web page URL, useful for returning to homepage or navigating to known pages.
156122
- type: 'GoBack', navigate back to the previous page
157123
* {{ param: null }}
158124
* use this action when you need to go back to the previous page in the browser history, similar to clicking the browser's back button.
@@ -446,41 +412,6 @@ class LLMPrompt:
446412
}
447413
```
448414
449-
#### Example 8: Return to Original Tab/Page (CRITICAL PATTERN)
450-
"Return to the original tab/page where we started"
451-
```json
452-
{
453-
"actions": [
454-
{
455-
"type": "GoToPage",
456-
"thought": "Using GoToPage for guaranteed navigation back to original URL. This is more reliable than clicking UI elements which may fail or behave unpredictably.",
457-
"param": {"url": "https://original-site.com/original-page"},
458-
"locate": null
459-
}
460-
],
461-
"taskWillBeAccomplished": true,
462-
"furtherPlan": null,
463-
"error": null
464-
}
465-
```
466-
467-
#### Counter-Example: What NOT to do for Navigation
468-
"Return to the original tab"
469-
```json
470-
// ❌ WRONG - Unreliable approach
471-
{
472-
"actions": [
473-
{
474-
"type": "Tap",
475-
"thought": "Click the site logo to return",
476-
"param": null,
477-
"locate": {"id": "1"}
478-
}
479-
],
480-
"error": "This approach is unreliable - UI elements may not achieve intended navigation"
481-
}
482-
```
483-
484415
#### Example of what NOT to do
485416
- If the action's `locate` is null and element is **not in the screenshot**, don't continue planning. Instead:
486417
```json

webqa_agent/testers/case_gen/prompts/agent_prompts.py

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -89,53 +89,6 @@ def get_execute_system_prompt(case: dict) -> str:
8989
- **Single Tool Call**: Execute only ONE `execute_ui_action` or `execute_ui_assertion` per instruction
9090
- **Error Handling**: If any action in the sequence fails, stop and report the error - do not attempt subsequent actions
9191
92-
## Navigation Reliability Guidelines (CRITICAL)
93-
94-
### Navigation Action Selection Priority
95-
When executing navigation-related actions, follow these reliability guidelines:
96-
97-
**1. Prefer URL-based Navigation (HIGHEST RELIABILITY - 100%)**
98-
- When returning to known pages, switching tabs, or navigating to specific URLs
99-
- Use direct URL navigation instead of clicking UI elements when URL is available
100-
- Example actions: "Return to homepage", "Go back to original page", "Switch to previous tab"
101-
- Implementation: Always request URL-based navigation when target URL is known
102-
103-
**2. Browser History Navigation (HIGH RELIABILITY - 95%)**
104-
- For sequential backward navigation through browser history
105-
- Use browser back functionality for natural user flow
106-
- Example actions: "Go back to previous page", "Navigate to previous form"
107-
108-
**3. UI Element Navigation (LOWER RELIABILITY - 60-80%)**
109-
- Use ONLY when target URL is unknown AND discovery is required
110-
- Warning: UI elements (logos, icons, menu items) may fail or behave inconsistently
111-
- Example actions: "Click unknown menu item", "Explore new section"
112-
113-
### Critical Navigation Decision Rules
114-
- **Known URL Available**: ALWAYS prefer URL-based over UI element clicking
115-
- **Returning to Original Tab**: Use URL navigation instead of clicking tab or logo
116-
- **Homepage Navigation**: Use direct URL instead of clicking logo
117-
- **Error Recovery**: If UI navigation fails, attempt URL-based fallback
118-
119-
### Navigation Error Handling
120-
**Navigation Failure Patterns**:
121-
- UI elements may not respond (disabled, hidden, non-functional)
122-
- Logo clicks may not navigate to expected pages
123-
- Tab switching via UI may fail in complex applications
124-
- Menu items may lead to unexpected destinations
125-
126-
**Navigation Recovery Strategy**:
127-
1. Detect navigation failure through page URL verification
128-
2. Identify target URL from context or previous navigation
129-
3. Attempt direct URL-based navigation as fallback
130-
4. Report navigation method and success/failure for analysis
131-
132-
### Navigation Success Validation
133-
After any navigation action, verify:
134-
- Current URL matches expected destination
135-
- Page content confirms successful navigation
136-
- No error messages or unexpected redirects occurred
137-
- Navigation state is stable for subsequent actions
138-
13992
## Test Execution Hierarchy (Priority Order)
14093
14194
### 1. Single Action Imperative (HIGHEST PRIORITY)

webqa_agent/testers/case_gen/prompts/planning_prompts.py

Lines changed: 1 addition & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -170,55 +170,7 @@ def get_shared_test_design_standards(language: str = 'zh-CN') -> str:
170170
- **Minimize Navigation**: Prefer testing multiple features on the same page before navigating away
171171
- **Logical Flow**: Follow realistic user navigation patterns and business workflows
172172
- **State Preservation**: Consider page state changes and user context throughout navigation
173-
- **Business Journey**: Align navigation with typical business user journeys and workflows
174-
175-
### Navigation Method Selection (CRITICAL)
176-
**PRIORITY**: When generating navigation steps, follow this reliability hierarchy:
177-
178-
**1. URL-Based Navigation (HIGHEST RELIABILITY - 100%)**
179-
- **Preferred Actions**: Use "Go to [URL]" or "Navigate to [page]" when target URL is known
180-
- **Use Cases**: Returning to original tab, going to homepage, switching between specific pages
181-
- **Examples**: "Go to homepage URL", "Return to original test page", "Navigate to product catalog"
182-
- **Rationale**: Direct URL manipulation is deterministic and never fails due to UI element issues
183-
184-
**2. Browser History Navigation (HIGH RELIABILITY - 95%)**
185-
- **Preferred Actions**: Use "Go back to previous page" for sequential navigation
186-
- **Use Cases**: Returning to previous forms, navigating backward through user flow
187-
- **Examples**: "Go back to search results", "Return to previous form page"
188-
189-
**3. UI Element Navigation (LOWER RELIABILITY - 60-80%)**
190-
- **Caution Required**: Use ONLY when target URL is unknown AND discovery is required
191-
- **Risk Factors**: UI elements (logos, icons, menu items) may fail or behave inconsistently
192-
- **Use Cases**: Exploring unknown menu items, discovering new functionality
193-
- **Examples**: "Click unknown navigation link", "Explore new menu section"
194-
195-
### Navigation Action Guidelines for Step Generation
196-
When generating navigation-related test steps:
197-
198-
1. **Check URL Availability**: If target destination URL is known or can be determined, ALWAYS prefer URL-based navigation
199-
2. **Avoid Risky UI Clicks**: Don't use "Click logo to return home" - use "Go to homepage URL" instead
200-
3. **Document Navigation Method**: Include reason for navigation method choice in step description
201-
4. **Provide Fallbacks**: If UI navigation fails, suggest URL-based alternatives
202-
203-
### Enhanced Navigation Examples
204-
```json
205-
// ✅ PREFERRED - URL-based navigation
206-
{{"action": "Go to homepage URL to restart the test flow"}}
207-
{{"action": "Navigate to https://example.com/products to test catalog"}}
208-
{{"action": "Return to original test page URL"}}
209-
210-
// ✅ ACCEPTABLE - Browser history navigation
211-
{{"action": "Go back to previous search results page"}}
212-
{{"action": "Use browser back to return to form"}}
213-
214-
// ⚠️ USE WITH CAUTION - UI element navigation
215-
{{"action": "Click 'Products' menu item to explore catalog"}}
216-
// Note: Only when URL is unknown or discovery is the goal
217-
218-
// ❌ AVOID - Risky UI navigation when URL is known
219-
{{"action": "Click logo to return to homepage"}}
220-
// Should be: {{"action": "Go to homepage URL"}}
221-
```"""
173+
- **Business Journey**: Align navigation with typical business user journeys and workflows"""
222174

223175

224176
def get_test_case_planning_system_prompt(
@@ -1457,36 +1409,4 @@ def get_dynamic_step_generation_prompt() -> str:
14571409
- **Mixed Elements**: Evaluate primary elements affecting objective
14581410
- **Insufficient Context**: Document uncertainty, use conservative approach
14591411
1460-
### Navigation Element Classification
1461-
1462-
**DECISION ALGORITHM - Apply in this exact order:**
1463-
1464-
1. Check for `href` attribute → If present, element IS navigable
1465-
2. Check for `target="_blank"` or `target="_new"` → If present, MUST test with click action
1466-
3. Check for `onclick` or `data-toggle` → If present, requires interaction testing
1467-
4. Check for `download` attribute → If present, requires download verification
1468-
1469-
**CRITICAL RULES:**
1470-
1471-
✅ **ALWAYS TEST these elements:**
1472-
- ANY element with `target="_blank"` → Opens new tab, MUST verify navigation
1473-
- Dropdown items with `href` → Are navigation links, NOT decorative
1474-
- Elements with both `href` and `target` → Priority test candidates
1475-
- Modal/popup triggers (`data-toggle="modal"`) → Require interaction verification
1476-
1477-
❌ **NEVER SKIP these as "passive":**
1478-
- Menu items with `target="_blank"` → These are active navigation elements
1479-
- Links with `rel="noopener"` or `rel="noreferrer"` → Security attributes indicate real links
1480-
- Dropdown options with URLs → These navigate to new pages/tabs
1481-
1482-
**ATTRIBUTE REFERENCE:**
1483-
- `target="_blank"`: Opens new browser tab - requires click test to verify behavior
1484-
- `href="#"` vs `href="https://..."`: First is page anchor, second is external navigation
1485-
- `download`: Triggers file download - verify download initiates correctly
1486-
- `rel="noopener noreferrer"`: Security for new tab links - confirms real navigation intent
1487-
1488-
**EXAMPLES:**
1489-
✅ CORRECT: "Model Arena" with `href="/arena" target="_blank"` → Generate: "Click 'Model Arena' to verify new tab navigation"
1490-
❌ WRONG: "Model Arena" with `target="_blank"` → Skip as "persistent UI indicator"
1491-
14921412
Remember: Quality over quantity. Generate only the most valuable steps that properly handle UI state transitions and element lifecycles."""

0 commit comments

Comments
 (0)