{"id":13566952,"url":"https://github.com/httprunner/har2case","last_synced_at":"2025-04-04T00:32:29.400Z","repository":{"id":42136510,"uuid":"110247840","full_name":"httprunner/har2case","owner":"httprunner","description":"Convert HAR(HTTP Archive) to YAML/JSON testcases for HttpRunner. Merged to httprunner/ext/har2case. ","archived":true,"fork":false,"pushed_at":"2019-07-19T08:33:23.000Z","size":71,"stargazers_count":110,"open_issues_count":2,"forks_count":41,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-11T01:08:12.827Z","etag":null,"topics":["har","http-archive","yaml"],"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/httprunner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-10T13:05:33.000Z","updated_at":"2025-02-28T17:49:27.000Z","dependencies_parsed_at":"2022-09-08T04:51:03.539Z","dependency_job_id":null,"html_url":"https://github.com/httprunner/har2case","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httprunner%2Fhar2case","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httprunner%2Fhar2case/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httprunner%2Fhar2case/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httprunner%2Fhar2case/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/httprunner","download_url":"https://codeload.github.com/httprunner/har2case/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247103290,"owners_count":20884023,"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":["har","http-archive","yaml"],"created_at":"2024-08-01T13:02:20.171Z","updated_at":"2025-04-04T00:32:29.096Z","avatar_url":"https://github.com/httprunner.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# har2case\n\n[![LICENSE](https://img.shields.io/github/license/HttpRunner/har2case.svg)](https://pypi.org/project/har2case/) [![travis-ci](https://travis-ci.org/HttpRunner/har2case.svg?branch=master)](https://travis-ci.org/HttpRunner/har2case) [![coveralls](https://coveralls.io/repos/github/HttpRunner/har2case/badge.svg?branch=master)](https://coveralls.io/github/HttpRunner/har2case?branch=master) [![pypi version](https://img.shields.io/pypi/v/har2case.svg)](https://pypi.python.org/project/har2case/) [![pyversions](https://img.shields.io/pypi/pyversions/har2case.svg)](https://pypi.python.org/project/har2case/)\n\nConvert HAR(HTTP Archive) to YAML/JSON testcases for HttpRunner.\n\n\n## install\n\n`har2case` is available on `PyPI` and can be installed through pip.\n\n```bash\n$ pip install har2case\n```\n\n## usage\n\nWhen `har2case` is installed, a **har2case** command should be available in your shell (if you're not using\nvirtualenv—which you should—make sure your python script directory is on your path).\n\nTo see `har2case` version:\n\n```bash\n$ har2case -V\n0.2.1\n```\n\nTo see available options, run:\n\n```text\n$ har2case -h\nusage: main.py [-h] [-V] [--log-level LOG_LEVEL] [-2y] [--filter FILTER]\n               [--exclude EXCLUDE]\n               [har_source_file]\n\nConvert HAR to YAML/JSON testcases for HttpRunner.\n\npositional arguments:\n  har_source_file       Specify HAR source file\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -V, --version         show version\n  --log-level LOG_LEVEL\n                        Specify logging level, default is INFO.\n  -2y, --to-yml, --to-yaml\n                        Convert to YAML format, if not specified, convert to\n                        JSON format by default.\n  --filter FILTER       Specify filter keyword, only url include filter string\n                        will be converted.\n  --exclude EXCLUDE     Specify exclude keyword, url that includes exclude\n                        string will be ignored, multiple keywords can be\n                        joined with '|'\n```\n\n## examples\n\nIn most cases, you can only specify har source file path. By default, `har2case` will generate testcase file in JSON format.\n\n```bash\n$ har2case tests/data/demo.har\nINFO:root:Start to generate testcase.\nINFO:root:dump testcase to JSON format.\nINFO:root:Generate JSON testcase successfully: tests/data/demo.json\n```\n\nIf you want to generate testcase file in YAML format, you can add `-2y` or `--to-yml` argument.\n\n```bash\n$ har2case tests/data/demo.har -2y\nINFO:root:Start to generate testcase.\nINFO:root:dump testcase to YAML format.\nINFO:root:Generate YAML testcase successfully: tests/data/demo.yaml\n```\n\nThe generated testcase file is in the same folder with the har source file and has the same name.\n\n**filter**\n\nYou can do some filter while conversion, only url that includes filter string will be converted.\n\n```bash\n$ har2case tests/data/demo.har --filter httprunner.org\n```\n\n**exclude**\n\nYou can also set exclude keyword while conversion, url that includes exclude string will be ignored.\n\n```bash\n$ har2case tests/data/demo.har --exclude debugtalk.com\n```\n\n## generated testcase\n\nGenerated YAML testcase `demo.yml` shows like below:\n\n```yaml\n-   config:\n        name: testcase description\n        variables: {}\n-   test:\n        name: /api/v1/Account/Login\n        request:\n            headers:\n                Content-Type: application/json\n                User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36\n                    (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36\n            json:\n                Pwd: '123'\n                UserName: test001\n                VerCode: ''\n            method: POST\n            url: https://httprunner.org/api/v1/Account/Login\n        validate:\n        -   eq:\n            - status_code\n            - 200\n        -   eq:\n            - headers.Content-Type\n            - application/json; charset=utf-8\n        -   eq:\n            - content.IsSuccess\n            - true\n        -   eq:\n            - content.Code\n            - 200\n        -   eq:\n            - content.Message\n            - null\n```\n\nAnd generated JSON testcase `demo.json` shows like this:\n\n```json\n[\n    {\n        \"config\": {\n            \"name\": \"testcase description\",\n            \"variables\": {}\n        }\n    },\n    {\n        \"test\": {\n            \"name\": \"/api/v1/Account/Login\",\n            \"request\": {\n                \"url\": \"https://httprunner.org/api/v1/Account/Login\",\n                \"method\": \"POST\",\n                \"headers\": {\n                    \"User-Agent\": \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36\",\n                    \"Content-Type\": \"application/json\"\n                },\n                \"json\": {\n                    \"UserName\": \"test001\",\n                    \"Pwd\": \"123\",\n                    \"VerCode\": \"\"\n                }\n            },\n            \"validate\": [\n                {\n                    \"eq\": [\n                        \"status_code\",\n                        200\n                    ]\n                },\n                {\n                    \"eq\": [\n                        \"headers.Content-Type\",\n                        \"application/json; charset=utf-8\"\n                    ]\n                },\n                {\n                    \"eq\": [\n                        \"content.IsSuccess\",\n                        true\n                    ]\n                },\n                {\n                    \"eq\": [\n                        \"content.Code\",\n                        200\n                    ]\n                },\n                {\n                    \"eq\": [\n                        \"content.Message\",\n                        null\n                    ]\n                }\n            ]\n        }\n    }\n]\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhttprunner%2Fhar2case","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhttprunner%2Fhar2case","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhttprunner%2Fhar2case/lists"}