{"id":15664387,"url":"https://github.com/gwuhaolin/chrome-runner","last_synced_at":"2025-05-06T19:11:12.173Z","repository":{"id":57198490,"uuid":"95282877","full_name":"gwuhaolin/chrome-runner","owner":"gwuhaolin","description":"run chrome with nodejs in code","archived":false,"fork":false,"pushed_at":"2018-04-10T05:15:53.000Z","size":55,"stargazers_count":16,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-03T13:42:44.901Z","etag":null,"topics":["chrome","chrome-runner","headless-chrome"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gwuhaolin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-24T07:32:25.000Z","updated_at":"2023-09-08T17:26:43.000Z","dependencies_parsed_at":"2022-09-16T14:10:20.661Z","dependency_job_id":null,"html_url":"https://github.com/gwuhaolin/chrome-runner","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/gwuhaolin%2Fchrome-runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gwuhaolin%2Fchrome-runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gwuhaolin%2Fchrome-runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gwuhaolin%2Fchrome-runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gwuhaolin","download_url":"https://codeload.github.com/gwuhaolin/chrome-runner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221152506,"owners_count":16765055,"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":["chrome","chrome-runner","headless-chrome"],"created_at":"2024-10-03T13:42:22.274Z","updated_at":"2024-10-23T03:41:37.740Z","avatar_url":"https://github.com/gwuhaolin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Npm Package](https://img.shields.io/npm/v/chrome-runner.svg?style=flat-square)](https://www.npmjs.com/package/chrome-runner)\n[![Build Status](https://img.shields.io/travis/gwuhaolin/chrome-runner.svg?style=flat-square)](https://travis-ci.org/gwuhaolin/chrome-runner)\n[![Build Status](https://img.shields.io/appveyor/ci/gwuhaolin/chrome-runner.svg?style=flat-square)](https://ci.appveyor.com/project/gwuhaolin/chrome-runner)\n[![Dependency Status](https://david-dm.org/gwuhaolin/chrome-runner.svg?style=flat-square)](https://npmjs.org/package/chrome-runner)\n[![Npm Downloads](http://img.shields.io/npm/dm/chrome-runner.svg?style=flat-square)](https://www.npmjs.com/package/chrome-runner)\n\n# chrome-runner\nRun chrome with ease from node.\n\n- Support OSX Linux Windows system\n- Handle chrome unexpected exit and restart it\n- Opens up the browser's `remote-debugging-port` on an available port\n- Automatic locates a Chrome binary to launch\n- Uses a fresh Chrome profile for each launch, and cleans itself up on `kill()`\n- Support typescript\n\n## Use\n```js\nconst {Runner,launch,launchWithoutNoise,launchWithHeadless} = require('chrome-runner');\n// launch a chrome, launch return a Runner instance\nconst runner = await launch();\n// read chrome remote debugging port\nrunner.port;\n// kill this chrome\nawait runner.kill();\n```\n\n### Options\n`launch()` method can pass options by `launch({name:value})`. Include:\n- `port`: {number} launch chrome listen on debug port, default will random a free port to use\n- `chromePath`: {string} chrome executable full path, default will automatic find a path according to your system. If no executable chrome find, will use env CHROME_PATH as executable full path. If all of the above way can't get a path a Error('no chrome installations found') will throw\n- `chromeFlags`: {Array\u003cstring\u003e} flags pass to chrome when start chrome, all flags can be find [here](http://peter.sh/experiments/chromium-command-line-switches/)\n- `startupPage`: {string} open page when chrome start, default is `about:blank`\n- `shouldRestartChrome`: {boole} logger to handle log from chrome-runner, interface like console, default use console\n- `monitorInterval`: {number} in ms, monitor chrome is alive interval, default is 500ms\n- `chromeDataDir`: {string} chrome data dir, default will create one in system tmp\n- `disableLogging`: {boolean} Controls if Chome stdout and stderr is logged to file, default is `true`.\n\n### Runner API\n- `runner.port`: get chrome remove debug port\n- `runner.kill()`: kill chrome and release all resource and remove temp files\n\n#### Events\nRunner extends EventEmitter, it will emit some events in it's lifecycle, Include:\n- `chromeAlive(port)`: when monitor detect chrome is alive\n- `chromeDead(code, signal)`: after monitor detect chrome is not alive\n- `chromeRestarted()`: after chrome unexpected exited then runner restart it\n- `chromeDataDirPrepared(chromeDataDir)`: after runner create data dir for chrome\n- `chromeDataDirRemoved(chromeDataDir)`: after remove successful create data dir for chrome\n\n### launchWithoutNoise\n`launchWithoutNoise` same with `launch` but [disables many chrome services](https://github.com/gwuhaolin/chrome-runner/blob/master/lib/flags.js) that add noise to automated scenarios.\n\n### launchWithHeadless\n`launchWithHeadless` same with `launch` but [run chrome in headless mode](https://developers.google.com/web/updates/2017/04/headless-chrome) and without noise.\n\n**more use case see [unit test](./test/runner.test.js), API detail see [d.ts](./index.d.ts)**\n\n### Chrome log files\nAfter chrome launched, chrome's log and pid file will be pipe to file in `chromeDataDir`, Include:\n- `chrome-out.log` chrome info log\n- `chrome-err.log` chrome error log\n- `chrome.pid` chrome pid file\n\n## Install chrome on linux server\nchrome-runner required chrome installed on your system, it easy to install on OSX and Windows, Linux server see [How to install Chrome browser properly via command line?](https://askubuntu.com/questions/79280/how-to-install-chrome-browser-properly-via-command-line)\n\n## Use Case\nchrome-runner has been used in many project, e.g:\n- [chrome-render](https://github.com/gwuhaolin/chrome-render) general server render base on chrome\n- [chrome-pool](https://github.com/gwuhaolin/chrome-pool) headless chrome tabs manage pool\n- [koa-seo](https://github.com/gwuhaolin/koa-seo) SEO middleware for koa base on chrome-render, a substitute for prerender\n- [chrome-tester](https://github.com/gwuhaolin/chrome-tester) web page automatic tester\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgwuhaolin%2Fchrome-runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgwuhaolin%2Fchrome-runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgwuhaolin%2Fchrome-runner/lists"}