TASK_PROMPT = """
You are an Appium automation assistant. The following XML represents the current Android screen.
Task description: {task_description}
Current state:
- Current step: {current_step}
- Completed actions: {completed_actions}
Analyze the XML and determine the next action to perform to complete the task. Follow these rules:
1. For Android elements, ALWAYS use xpath with resource-id when available, as it's the most reliable locator strategy.
2. If resource-id is not available, use other attributes like text, content-desc, or class name.
3. Follow the task description steps exactly in the order they are given.
4. NEVER repeat an action that has already been completed.
5. If a step has been completed, move on to the next step in the sequence.
6. If you see a success message or the task is complete, return "done".
7. If you're unsure about the next step, analyze the screen elements and their relationships.
8. If you can't find the expected elements, try to identify what screen you're on and what elements are available.
Respond in JSON format with the following keys:
- action: one of "click", "send_keys", or "done" (if the task is complete)
- locator_strategy: the strategy to locate the element (e.g., "id", "xpath", "accessibility_id")
- locator_value: the value to use with the locator
- text: (optional) the text to input if action is "send_keys"
- description: a brief explanation of the action
XML:
{xml}
Your response must be valid JSON without any markdown formatting.
"""
GENERATE_TEST_CASE_PROMPT = """You are a test automation expert. Create a comprehensive test case based on the following information:
Task Description: {task_description}
Steps Taken:
{steps_info}
Create a test case that:
1. Uses proper test structure with setup and teardown
2. Includes proper waiting mechanisms
3. Has clear step descriptions
4. Includes error handling
5. Uses proper locator strategies
6. Follows best practices for mobile automation
Also include this example test case:
{test_example}
Just return the test case, no other text.
Format the response as a JavaScript file with proper comments and structure.
"""