)
# 基础安装 # 包括 OpenAI-, Gemini-, and Ollama-compatible model support pip install robotframework-aitester # 支持 web 测试 pip install robotframework-aitester[web] # 支持 API 测试 pip install robotframework-aitester[api] # 支持 mobile 测试 pip install robotframework-aitester[mobile] # 支持所有测试模式 pip install robotframework-aitester[all] # 支持 Bedrock pip install robotframework-aitester[all,bedrock] # 支持 Anthropic pip install robotframework-aitester[all,anthropic] # Development pip install robotframework-aitester[all,anthropic,bedrock,dev]推荐的生产环境安装pip install robotframework-aitester[web] 基于Selenium的UI测试 pip install robotframework-aitester[api] 基于RequestsLibrary的API测试 pip install robotframework-aitester[mobile] 基于Appium的移动端测试 基础安装已通过 strands-agents[openai,ollama,gemini] 包含 OpenAI、Gemini 和 Ollama 提供者的支持 仅在您选择的 GenAI 后端需要这些可选提供者时才添加 [anthropic] 或 [bedrock]3.快速入门前置条件对于确定性网页运行在使用 SeleniumLibrary 调用 Run AI Test 或 Run AI Exploration 之前需先打开目标浏览器。对于确定性移动端运行在使用 AppiumLibrary 调用 Run AI Mobile Test 或 Run AI Exploration 之前需启动 Appium 服务器、设备或模拟器并打开应用程序。对于 API 运行需在测试套件中加载 RequestsLibrary并在适当情况下提供 base_url 或已初始化的会话上下文。安装针对目标模式和提供者的必要扩展。如果 SeleniumLibrary、RequestsLibrary 或 AppiumLibrary 使用别名导入请传递相应的 selenium_library 、 requests_library 或 appium_library 构造函数参数以便 AITester 可以附加到现有会话。Web 测试*** Settings *** Library SeleniumLibrary Library AITester platformOpenAI api_key%{OPENAI_API_KEY} modelgpt-4o *** Test Cases *** AI Login Flow Test [Documentation] AI agent autonomously tests the login functionality Open Browser https://myapp.example.com chrome ${TEST_STEPS} Set Variable ... Test Steps: ... 1. Open the login page ... 2. Attempt login with valid credentials and verify success ... 3. Attempt login with invalid credentials and verify error message ${status} Run AI Test ... test_objectiveTest the login functionality including valid credentials, ... invalid credentials, empty fields, and password recovery flow ... app_contextE-commerce web application with email/password login ... test_steps${TEST_STEPS} ... max_iterations50 Log ${status} [Teardown] Close All Browsers AI Exploratory Testing [Documentation] AI agent freely explores and tests the application Open Browser https://myapp.example.com chrome ${status} Run AI Exploration ... app_contextE-commerce platform with product catalog, shopping cart and checkout ... focus_areasnavigation, search, product filtering, cart operations ... max_iterations100 Log ${status} [Teardown] Close All Browsers由 Open Browser 打开的浏览器会被代理重用。如果会话已经处于活动状态AITester 将重用它并拒绝打开新的会话。当提供编号为 test_steps 的步骤时这些步骤被视为主流程并按顺序直接执行无需单独的规划交接。这些步骤被视为意图检查点而不是像素级完美的脚本。只要请求的业务流程保持完整代理可能会插入最小的支持操作例如关闭 Cookie 横幅、打开菜单、等待页面稳定或遇到临时拦截器后重试。如果流程遇到硬性障碍代理不会停止并等待人工干预。它会首先尝试通过 get_rf_variable 获取套件提供的数据、安全的替代可见路径以及证据捕获然后精确地失败被阻塞的步骤。API 测试*** Settings *** Library RequestsLibrary Library AITester platformOllama modelllama3.3 *** Test Cases *** AI REST API Test Create Session api https://api.example.com ${TEST_STEPS} Set Variable ... Test Steps: ... 1. Create a user via POST /users ... 2. Fetch the user via GET /users/{id} ... 3. Update the user via PUT /users/{id} ... 4. Delete the user via DELETE /users/{id} ${status} Run AI API Test ... test_objectiveTest the user management API endpoints including ... CRUD operations, authentication, error handling, and edge cases ... base_urlhttps://api.example.com ... api_spec_urlhttps://api.example.com/openapi.json ... test_steps${TEST_STEPS} ... max_iterations30 Log ${status}Mobile 测试*** Settings *** Library AppiumLibrary Library AITester platformGemini api_key%{GEMINI_API_KEY} *** Test Cases *** AI Mobile App Test Open Application http://localhost:4723/wd/hub ... platformNameAndroid appcom.example.app ${TEST_STEPS} Set Variable ... Test Steps: ... 1. Complete the onboarding flow ... 2. Navigate to the main dashboard ... 3. Open settings and verify key options ${status} Run AI Mobile Test ... test_objectiveTest the onboarding flow, main navigation and settings screen ... app_contextAndroid banking application ... test_steps${TEST_STEPS} ... max_iterations40 Log ${status} [Teardown] Close Application对于移动端测试AITester 需要一个活跃的 AppiumLibrary 会话并且当 app_context 和编号的 test_steps 能够明确目标屏幕、账户状态和预期路径时效果最佳。现在它能够等待加载指示器、处理常见的选择器、隐藏屏幕键盘、切换混合上下文并使用返回导航而无需降级到原始的 Appium 命令。对于移动探索性测试导入库时使用 test_modemobile 然后调用 Run AI Exploration 。4.支持的 AI 平台PlatformDefault ModelProviderNotesOpenAIgpt-4oOpenAI API需要OPENAI_API_KEYOllamallama3.3本地 Ollama免费本地推理Docker Modelai/qwen3-vl:8B-Q8_K_XL本地 Docker 模型运行器免费本地推理Geminigemini-2.0-flashGoogle AI需要GEMINI_API_KEYAnthropicclaude-sonnet-4-5Anthropic API需要ANTHROPIC_API_KEYBedrockus.anthropic.claude-sonnet-4-5-20251101-v1:0AWS Bedrock使用 AWS 凭证Manual用户指定OpenAI 兼容使用您自己的兼容端点通常与显式的model和base_url配合使用模型参数ParameterDefaultDescriptionplatformOpenAIAI 平台OpenAI、Ollama、Gemini 等model(varies)模型 IDapi_key(env var)API 密钥对于 Docker 模型始终使用 dummy 因此会被忽略base_url(varies)AI 提供者基础 URLmax_iterations50最大 agent 迭代次数test_modeweb默认测试模式web、api、mobileheadlessFalse作为配置元数据存储浏览器/应用启动仍由 SeleniumLibrary/AppiumLibrary 管理screenshot_on_actionTrue保留用于未来截图策略调整当前提示/工具调用仍决定何时进行截图verboseFalse启用详细代理日志记录selenium_librarySeleniumLibrarySeleniumLibrary 已有会话的名称/别名requests_libraryRequestsLibraryRequestsLibrary 已有会话的名称/别名appium_libraryAppiumLibraryAppiumLibrary 已有会话的名称/别名timeout_seconds600配置 SafetyGuard 超时元数据max_cost_usdNone配置 SafetyGuard 成本限制元数据如果你使用别名导入 SeleniumLibrary/RequestsLibrary/AppiumLibrary请传递相应的 *_library 参数以便 AI 工具连接到已打开的会话。对于 platformDockerModel AITester 会自动将 api_keydummy 传递给兼容 OpenAI 的 Strands 客户端。对于该平台无需设置环境变量或构造函数参数。对于 platformManual 请自行提供与 OpenAI 兼容的端点详细信息通常需要同时包含 model 和 base_url 如有需要还需包含 api_key 。重要提示AITester 只能驱动由 SeleniumLibrary/AppiumLibrary 创建的会话。如果你手动打开浏览器/应用或通过其他工具打开代理将无法与其交互。5.关键字KeywordDescriptionRun AI Test从测试目标执行自主测试支持test_steps,scroll_into_view)Run AI Exploration使用库中配置的test_mode支持scroll_into_view进行探索性测试并关注重点区域Run AI API Test执行自主 REST API 测试支持test_steps,scroll_into_view)Run AI Mobile Test执行自主移动应用测试支持test_steps,scroll_into_view)Get AI Platform Info返回配置的平台信息