{"id":13501495,"url":"https://github.com/SeldomQA/seldom","last_synced_at":"2025-03-29T09:30:38.574Z","repository":{"id":37432309,"uuid":"39141541","full_name":"SeldomQA/seldom","owner":"SeldomQA","description":"Seldom automation testing framework based on unittest","archived":false,"fork":false,"pushed_at":"2024-10-24T03:06:22.000Z","size":10935,"stargazers_count":802,"open_issues_count":16,"forks_count":328,"subscribers_count":51,"default_branch":"master","last_synced_at":"2024-10-29T17:23:38.837Z","etag":null,"topics":["appium","python","requests","selenium","test-framework","unittest"],"latest_commit_sha":null,"homepage":"https://seldomqa.github.io/","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":"2015-07-15T14:29:33.000Z","updated_at":"2024-10-24T03:06:27.000Z","dependencies_parsed_at":"2023-10-22T10:43:41.452Z","dependency_job_id":"cd2b926a-0c32-4f23-be00-b60ff0802869","html_url":"https://github.com/SeldomQA/seldom","commit_stats":{"total_commits":1224,"total_committers":22,"mean_commits":55.63636363636363,"dds":"0.45261437908496727","last_synced_commit":"b84a400a8aca6ee93bda95337cfa18a0c4af02ed"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeldomQA%2Fseldom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeldomQA%2Fseldom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeldomQA%2Fseldom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeldomQA%2Fseldom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SeldomQA","download_url":"https://codeload.github.com/SeldomQA/seldom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245823302,"owners_count":20678173,"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":["appium","python","requests","selenium","test-framework","unittest"],"created_at":"2024-07-31T22:01:39.400Z","updated_at":"2025-03-29T09:30:38.567Z","avatar_url":"https://github.com/SeldomQA.png","language":"Python","readme":"[GitHub](https://github.com/SeldomQA/seldom) | [Gitee](https://gitee.com/fnngj/seldom) |\n\n![](./images/seldom_logo.jpg)\n\n[![PyPI version](https://badge.fury.io/py/seldom.svg)](https://badge.fury.io/py/seldom) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/seldom)\n\nSeldom is an automation testing framework based on unittest.\n\n\u003e seldom 是基于unittest 的自动化测试框架。\n\n### Features\n\n⭐ web/app/api全功能测试框架\n\n⭐ 提供脚手架快速创建自动化项目\n\n⭐ 集成`XTestRunner`测试报告，现代美观\n\n⭐ 提供丰富的断言\n\n⭐ 提供强大的`数据驱动`\n\n⭐ 平台化支持\n\n### Install\n\n```shell\npip install seldom\n```\n\nIf you want to keep up with the latest version, you can install with GitHub/Gitee repository url:\n\n```shell\n\u003e pip install -U git+https://github.com/SeldomQA/seldom.git@master\n\u003e pip install -U git+https://gitee.com/fnngj/seldom.git@master\n```\n\n### 🤖 Quick Start\n\n1、查看帮助：\n\n```shell\nseldom --help\nUsage: seldom [OPTIONS]\n\n  seldom CLI.\n\nOptions:\n  --version                       Show version.\n  --project-api TEXT              Create an API automation test project.\n  --project-app TEXT              Create an App automation test project.\n  --project-web TEXT              Create an Web automation test project.\n  -cc, --clear-cache BOOLEAN      Clear all caches of seldom.\n  -p, --path TEXT                 Run test case file path.\n  -c, --collect / -nc, --no-collect\n                                  Collect project test cases. Need the\n                                  `--path`.\n  -l, --level [data|method]       Parse the level of use cases. Need the\n                                  --path.\n  -j, --case-json TEXT            Test case files. Need the `--path`.\n  -e, --env TEXT                  Set the Seldom run environment `Seldom.env`.\n  -b, --browser [chrome|firefox|ie|edge|safari]\n                                  The browser that runs the Web UI automation\n                                  tests. Need the `--path`.\n  -u, --base-url TEXT             The base-url that runs the HTTP automation\n                                  tests. Need the `--path`.\n  -d, --debug / -nd, --no-debug   Debug mode. Need the `--path`.\n  -rr, --rerun INTEGER            The number of times a use case failed to run\n                                  again. Need the `--path`.\n  -r, --report TEXT               Set the test report for output. Need the\n                                  `--path`.\n  -m, --mod TEXT                  Run tests modules, classes or even\n                                  individual test methods from the command\n                                  line.\n  -ll, --log-level [TRACE|DEBUG|INFO|SUCCESS|WARNING|ERROR]\n                                  Set the log level.\n  -h2c, --har2case TEXT           HAR file converts an seldom test case.\n  -s2c, --swagger2case TEXT       Swagger file converts an seldom test case.\n  --api-excel TEXT                Run the api test cases in the excel file.\n  --help                          Show this message and exit.\n```\n\n2、创建项目：\n\n```shell\n\u003e seldom --project-api myapi  # API automation test project.\n\u003e seldom --project-app myapp  # or App automation test project.\n\u003e seldom --project-web myweb  # or Web automation test project.\n```\n\n目录结构如下：\n\n```shell\nmyweb/\n├── test_dir/\n│   ├── __init__.py\n│   └── test_sample.py\n├── test_data/\n│   └── data.json\n├── reports/\n└── confrun.py\n```\n\n* `test_dir/` 测试用例目录。\n* `test_data/` 测试数据文件目录。\n* `reports/` 测试报告目录。\n* `confrun.py` 运行配置文件。\n\n3、运行项目：\n\n* ❌️ 在`PyCharm`中右键执行。\n\n* ✔️ 通过命令行工具执行。\n\n```shell\n\u003e seldom -p test_dir # 运行 test_dir 测试目录\n\n\n              __    __\n   ________  / /___/ /___  ____ ____\n  / ___/ _ \\/ / __  / __ \\/ __ ` ___/\n (__  )  __/ / /_/ / /_/ / / / / / /\n/____/\\___/_/\\__,_/\\____/_/ /_/ /_/  v3.x.x\n-----------------------------------------\n                             @itest.info\n...\n\n2022-04-30 18:37:36 log.py | INFO | ✅ Find 1 element: id=sb_form_q  -\u003e input 'seldom'.\n2022-04-30 18:37:39 log.py | INFO | 👀 assertIn title: seldom - 搜索.\n.52022-04-30 18:37:39 log.py | INFO | 📖 https://cn.bing.com\n2022-04-30 18:37:41 log.py | INFO | ✅ Find 1 element: id=sb_form_q  -\u003e input 'poium'.\n2022-04-30 18:37:42 log.py | INFO | 👀 assertIn title: poium - 搜索.\n.62022-04-30 18:37:42 log.py | INFO | 📖 https://cn.bing.com\n2022-04-30 18:37:43 log.py | INFO | ✅ Find 1 element: id=sb_form_q  -\u003e input 'XTestRunner'.\n2022-04-30 18:37:44 log.py | INFO | 👀 assertIn title: XTestRunner - 搜索.\n.72022-04-30 18:37:44 log.py | INFO | 📖 http://www.itest.info\n2022-04-30 18:37:52 log.py | INFO | 👀 assertIn url: http://www.itest.info/.\n.82022-04-30 18:37:52 log.py | SUCCESS | generated html file: file:///D:\\mypro\\reports\\2022_04_30_18_37_29_result.html\n2022-04-30 18:37:52 log.py | SUCCESS | generated log file: file:///D:\\mypro\\reports\\seldom_log.log\n```\n\n4、查看报告\n\n你可以到 `mypro\\reports\\` 目录查看测试报告。\n\n![test report](./images/test_report.png)\n\n## 🔬 Demo\n\n\u003e seldom继承unittest单元测试框架，完全遵循unittest编写用例规范。\n\n[demo](/demo) 提供了丰富实例，帮你快速了解seldom的用法。\n\n### Web UI 测试\n\n```python\nimport seldom\nfrom seldom import Steps\n\n\nclass BaiduTest(seldom.TestCase):\n\n    def test_case_one(self):\n        \"\"\"a simple test case \"\"\"\n        self.open(\"https://www.baidu.com\")\n        self.type(id_=\"kw\", text=\"seldom\")\n        self.click(css=\"#su\")\n        self.assertTitle(\"seldom_百度搜索\")\n\n    def test_case_two(self):\n        \"\"\"method chaining \"\"\"\n        Steps().open(\"https://www.baidu.com\").find(\"#kw\").type(\"seldom\").find(\"#su\").click()\n        self.assertTitle(\"seldom_百度搜索\")\n\n\nif __name__ == '__main__':\n    seldom.main(browser=\"chrome\")\n```\n\n__说明：__\n\n* `seldom.main()` 通过 `browser` 指定运行的浏览器。\n\n### HTTP 测试\n\nseldom 2.0 支持HTTP测试\n\n```python\nimport seldom\n\n\nclass TestRequest(seldom.TestCase):\n\n    def test_put_method(self):\n        self.put('/put', data={'key': 'value'})\n        self.assertStatusCode(200)\n\n    def test_post_method(self):\n        self.post('/post', data={'key': 'value'})\n        self.assertStatusCode(200)\n\n    def test_get_method(self):\n        payload = {'key1': 'value1', 'key2': 'value2'}\n        self.get(\"/get\", params=payload)\n        self.assertStatusCode(200)\n\n    def test_delete_method(self):\n        self.delete('/delete')\n        self.assertStatusCode(200)\n\n\nif __name__ == '__main__':\n    seldom.main(base_url=\"http://httpbin.org\")\n```\n\n__说明：__\n\n* `seldom.main()` 通过 `base_url` 指定接口项目基本URL地址。\n\n### App 测试\n\nseldom 3.0 支持App测试\n\n```python\nimport seldom\nfrom seldom.appium_lab.keyboard import KeyEvent\nfrom seldom.appium_lab.android import UiAutomator2Options\n\n\nclass TestBingApp(seldom.TestCase):\n\n    def start(self):\n        self.ke = KeyEvent(self.driver)\n\n    def test_bing_search(self):\n        \"\"\"\n        test bing App search\n        \"\"\"\n        self.sleep(2)\n        self.click(id_=\"com.microsoft.bing:id/sa_hp_header_search_box\")\n        self.type(id_=\"com.microsoft.bing:id/sapphire_search_header_input\", text=\"seldomQA\")\n        self.ke.press_key(\"ENTER\")\n        self.sleep(1)\n        elem = self.get_elements(xpath='//android.widget.TextView')\n        self.assertIn(\"seldom\", elem[0].text.lower())\n\n\nif __name__ == '__main__':\n    capabilities = {\n        'deviceName': 'ELS-AN00',\n        'automationName': 'UiAutomator2',\n        'platformName': 'Android',\n        'appPackage': 'com.microsoft.bing',\n        'appActivity': 'com.microsoft.sapphire.app.main.MainSapphireActivity',\n        'noReset': True,\n    }\n    options = UiAutomator2Options().load_capabilities(capabilities)\n    seldom.main(app_server=\"http://127.0.0.1:4723\", app_info=options, debug=True)\n```\n\n__说明：__\n\n* `seldom.main()` 通过 `app_info` 指定App信息； `app_server` 指定appium server 地址。\n\n## 📖 Document\n\n[中文文档](https://seldomqa.github.io/)\n\n### 项目实例\n\n基于seldom的web UI自动化项目：\n\nhttps://github.com/SeldomQA/seldom-web-testing\n\n基于seldom的接口自动化项目:\n\nhttps://github.com/defnngj/seldom-api-testing\n\n## 微信（WeChat）\n\n\u003e 相关书籍推荐， 基于 SeldomQA 相关开源项目，虫师 编著。\n\n\u003cp\u003e\n  \u003ca href=\"https://item.jd.com/14859108.html\"\u003e\n    \u003cimg alt=\"京东链接\" src=\"./images/book.jpg\" style=\"width: 220px; margin-right: 140px;\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e 欢迎添加微信，交流和反馈问题。\n\n\u003cdiv style=\"display: flex;justify-content: space-between;width: 100%\"\u003e\n    \u003cp\u003e\u003cimg alt=\"微信\" src=\"./images/wechat.jpg\" style=\"width: 200px;height: 100%\" \u003e\u003c/p\u003e\n\u003c/div\u003e\n\n### Star History\n\n![Star History Chart](https://api.star-history.com/svg?repos=SeldomQA/seldom\u0026type=Date)\n\n### 感谢\n\n感谢从以下项目中得到思路和帮助。\n\n* [parameterized](https://github.com/wolever/parameterized)\n\n* [utx](https://github.com/jianbing/utx)\n\n### 贡献者\n\n\u003ca href=\"https://github.com/SeldomQA/seldom/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=SeldomQA/seldom\" /\u003e\n\u003c/a\u003e\n\n### 交流\n\nQQ群：948994709\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSeldomQA%2Fseldom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSeldomQA%2Fseldom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSeldomQA%2Fseldom/lists"}