{"id":25253248,"url":"https://github.com/seldomqa/auto-wing","last_synced_at":"2025-10-27T00:30:57.477Z","repository":{"id":274121009,"uuid":"920602339","full_name":"SeldomQA/auto-wing","owner":"SeldomQA","description":"auto-wing is a tool that uses LLM to assist automated testing","archived":false,"fork":false,"pushed_at":"2025-02-11T09:43:47.000Z","size":1293,"stargazers_count":12,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-11T10:37:40.678Z","etag":null,"topics":["deepseek","openai","playwright","qwen","selenium"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SeldomQA.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-22T12:55:39.000Z","updated_at":"2025-02-11T09:43:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"91d2a92c-d89b-4a7d-9e1c-bd9a818a4c38","html_url":"https://github.com/SeldomQA/auto-wing","commit_stats":null,"previous_names":["seldomqa/auto-wing"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeldomQA%2Fauto-wing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeldomQA%2Fauto-wing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeldomQA%2Fauto-wing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeldomQA%2Fauto-wing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SeldomQA","download_url":"https://codeload.github.com/SeldomQA/auto-wing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238416234,"owners_count":19468456,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deepseek","openai","playwright","qwen","selenium"],"created_at":"2025-02-12T04:58:48.092Z","updated_at":"2025-10-27T00:30:57.470Z","avatar_url":"https://github.com/SeldomQA.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# auto-wing\n\n![](auto-wing.png)\n\n\u003e auto-wing is a tool that uses LLM to assist automated testing, give your automated testing wings.\n\nauto-wing是一个利用LLM辅助自动化测试的工具, 为你的自动化测试插上翅膀。\n\n### Features\n\n⭐ 集成 `playwright`、`selenium`、`appium`，支持`Web UI`和`App UI`的`AI`操作。\n\n⭐ 支持多模型：`openai`、`deepseek`、`qwen` 和 `doubao`。\n\n⭐ 支持多种操作：`ai_action`、`ai_query`、`ai_assert`。\n\n⭐ 默认支持缓存：首次执行AI任务会被缓存，后续执行相同的任务可以提升效率。\n\n⭐ 无痛的集成到现有自动化项目（`pytest`、`unittest`）中。\n\n## Install\n\n* 支持pip安装，`python \u003e= 3.9`。\n\n```shell\npip install autowing\n```\n\n## Setting Env\n\n__方法一__\n\n申请LLM需要的key，在项目的根目录下创建`.env`文件。推荐`qwen`和 `deepseek`，一是便宜，二是方便。\n\n* openai: https://platform.openai.com/\n\n```ini\n#.env\nAUTOWING_MODEL_PROVIDER = openai\nOPENAI_API_KEY = sk-proj-abdefghijklmnopqrstwvwxyz0123456789\n```\n\n* DeepSeek: https://platform.deepseek.com/\n\n```ini\n#.env\nAUTOWING_MODEL_PROVIDER = deepseek\nDEEPSEEK_API_KEY = sk-abdefghijklmnopqrstwvwxyz0123456789\n```\n\n* 阿里云百练（千问）：https://bailian.console.aliyun.com/\n\n```ini\n#.env\nAUTOWING_MODEL_PROVIDER = qwen\nDASHSCOPE_API_KEY = sk-abdefghijklmnopqrstwvwxyz0123456789\n```\n\n* 火山方舟（豆包）：https://console.volcengine.com/\n\n```ini\n#.env\nAUTOWING_MODEL_PROVIDER = doubao\nARK_API_KEY = f61d2846-xxx-xxx-xxxx-xxxxxxxxxxxxx\nDOUBAO_MODEL_NAME = ep-20250207200649-xxx\n```\n\n__方法二__\n\n\u003e 如果不想使用python-dotenv配置环境变量，可以直接配置环境变量。\n\n```shell\nexport AUTOWING_MODEL_PROVIDER=deepseek\nexport DEEPSEEK_API_KEY=sk-abdefghijklmnopqrstwvwxyz0123456789\n```\n\n\u003e 其他LLM模型环境变量同样的方式配置。\n\n## Examples\n\n👉 [查看 examples](./examples)\n\n```python\nimport pytest\nfrom playwright.sync_api import Page, sync_playwright\nfrom autowing.playwright.fixture import create_fixture\nfrom dotenv import load_dotenv\n\n\n@pytest.fixture(scope=\"session\")\ndef page():\n    \"\"\"playwright page fixture\"\"\"\n    # load .env file config\n    load_dotenv()\n    with sync_playwright() as p:\n        browser = p.chromium.launch(headless=False)\n        context = browser.new_context()\n        page = context.new_page()\n        yield page\n        context.close()\n        browser.close()\n\n\n@pytest.fixture\ndef ai(page):\n    \"\"\"ai fixture\"\"\"\n    ai_fixture = create_fixture()\n    return ai_fixture(page)\n\n\ndef test_bing_search(page: Page, ai):\n    # 访问必应\n    page.goto(\"https://cn.bing.com\")\n\n    # 使用AI执行搜索\n    ai.ai_action('搜索输入框输入\"playwright\"关键字，并回车')\n    page.wait_for_timeout(3000)\n\n    # 使用AI查询搜索结果\n    items = ai.ai_query('string[], 搜索结果列表中包含\"playwright\"相关的标题')\n\n    # 验证结果\n    assert len(items) \u003e 1\n\n    # 使用AI断言\n    assert ai.ai_assert('检查搜索结果列表第一条标题是否包含\"playwright\"字符串')\n```\n\n* 运行日志：\n\n```shell\n\u003e pytest test_playwright_pytest.py -s\n================================================= test session starts =================================================\nplatform win32 -- Python 3.12.3, pytest-8.3.4, pluggy-1.5.0\nrootdir: D:\\github\\seldomQA\\auto-wing\nconfigfile: pyproject.toml\nplugins: base-url-2.1.0, playwright-0.6.2\ncollected 1 item\n\ntest_playwright_pytest.py 2025-02-04 10:00:30.961 | INFO     | autowing.playwright.fixture:ai_action:88 - 🪽 AI Action: 搜索输入框输入\"playwright\"关键字，并回车\n2025-02-04 10:00:40.070 | INFO     | autowing.playwright.fixture:ai_query:162 - 🪽 AI Query: string[], 搜索结果列表中包 含\"playwright\"相关的标题\n2025-02-04 10:00:48.954 | DEBUG    | autowing.playwright.fixture:ai_query:218 - 📄 Query: ['Playwright 官方文档 | Playwright', 'Playwright - 快速、可靠的端到端测试框架', 'Playwright 中文文档 | Playwright', 'Playwright 入门指南 | Playwright', 'Playwright 测试框架 | Playwright', 'Playwright 教程 | Playwright', 'Playwright 使用指南 | Playwright', 'Playwright 自动化测试工具 | Playwright', 'Playwright 安装与配置 | Playwright', 'Playwright 示例代码 | Playwright']\n2025-02-04 10:00:48.954 | INFO     | autowing.playwright.fixture:ai_assert:267 - 🪽 AI Assert: 检查搜索结果列表第一条标 题是否包含\"playwright\"字符串\n.\n\n================================================= 1 passed in 27.99s ==================================================\n```\n\n## Prompting Tips\n\n__1.提供更详细的描述以及样例__\n\n提供详细描述和示例一直是非常有用的提示词技巧。\n\n错误示例 ❌: `\"搜'耳机'\"`\n\n正确示例 ✅: `\"找到搜索框（搜索框的上方应该有区域切换按钮，如 '国内'， '国际')，输入'耳机'，敲回车\"`\n\n错误示例 ❌: `\"断言：外卖服务正在正常运行\"`\n\n正确示例 ✅: `\"断言：界面上有个“外卖服务”的板块，并且标识着“正常”\"`\n\n__2.一个 Prompt (指令)只做一件事__\n\n尽管 auto-wing 有自动重规划能力，但仍应保持指令简洁。否则，LLM 的输出可能会变得混乱。指令的长度对 token 消耗的影响几乎可以忽略不计。\n\n错误示例 ❌:`\"点击登录按钮，然后点击注册按钮，在表单中输入'test@test.com'作为邮箱，'test'作为密码，然后点击注册按钮\"`\n\n正确示例\n✅: `将任务分解为三个步骤：\"点击登录按钮\" \"点击注册按钮\" \"在表单中输入'test@test.com'作为邮箱，'test'作为密码，然后点击注册按钮\"`\n\n__3.从界面做推断，而不是 DOM 属性或者浏览器状态__\n\n所有传递给 LLM 的数据都是截图和元素坐标。DOM和浏览器 对 LLM 来说几乎是不可见的。因此，务必确保你想提取的信息都在截图中有所体现且能被\nLLM “看到”。\n\n正确示例 ✅：`标题是蓝色的`\n\n错误实例 ❌：`标题有个 test-id-size 属性`\n\n错误实例 ❌：`浏览器有两个 tab 开着`\n\n错误实例 ❌：`异步请求已经结束了`\n\n__4.中、英文提示词无影响__\n\n由于大多数 AI 模型可以理解多种语言，所以请随意用你喜欢的语言撰写提示指令。即使提示语言与页面语言不同，通常也是可行的。\n\n### 交流\n\n\u003e 欢迎添加微信，交流和反馈问题。\n\n\u003cdiv style=\"display: flex;justify-content: space-between;width: 100%\"\u003e\n    \u003cp\u003e\u003cimg alt=\"微信\" src=\"./wechat.jpg\" style=\"width: 200px;height: 100%\" \u003e\u003c/p\u003e\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseldomqa%2Fauto-wing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseldomqa%2Fauto-wing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseldomqa%2Fauto-wing/lists"}