Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. # Chrome Launcher [![Linux Build Status](https://img.shields.io/travis/GoogleChrome/chrome-launcher/master.svg)](https://travis-ci.org/GoogleChrome/chrome-launcher) [![Windows Build Status](https://img.shields.io/appveyor/ci/paulirish/chrome-launcher/master.svg)](https://ci.appveyor.com/project/paulirish/chrome-launcher/branch/master) [![NPM chrome-launcher package](https://img.shields.io/npm/v/chrome-launcher.svg)](https://npmjs.org/package/chrome-launcher)
  2. <img src="https://user-images.githubusercontent.com/39191/29847271-a7ba82f8-8ccf-11e7-8d54-eb88fdf0b6d0.png" align=right height=200>
  3. Launch Google Chrome with ease from node.
  4. * [Disables many Chrome services](https://github.com/GoogleChrome/chrome-launcher/blob/master/src/flags.ts) that add noise to automated scenarios
  5. * Opens up the browser's `remote-debugging-port` on an available port
  6. * Automagically locates a Chrome binary to launch
  7. * Uses a fresh Chrome profile for each launch, and cleans itself up on `kill()`
  8. * Binds `Ctrl-C` (by default) to terminate the Chrome process
  9. * Exposes a small set of [options](#api) for configurability over these details
  10. Once launched, interacting with the browser must be done over the [devtools protocol](https://chromedevtools.github.io/devtools-protocol/), typically via [chrome-remote-interface](https://github.com/cyrus-and/chrome-remote-interface/). For many cases [Puppeteer](https://github.com/GoogleChrome/puppeteer) is recommended, though it has its own chrome launching mechanism.
  11. ### Installing
  12. ```sh
  13. yarn add chrome-launcher
  14. # or with npm:
  15. npm install chrome-launcher
  16. ```
  17. ## API
  18. ### `.launch([opts])`
  19. #### Launch options
  20. ```js
  21. {
  22. // (optional) remote debugging port number to use. If provided port is already busy, launch() will reject
  23. // Default: an available port is autoselected
  24. port: number;
  25. // (optional) Additional flags to pass to Chrome, for example: ['--headless', '--disable-gpu']
  26. // See: https://github.com/GoogleChrome/chrome-launcher/blob/master/docs/chrome-flags-for-tools.md
  27. // Do note, many flags are set by default: https://github.com/GoogleChrome/chrome-launcher/blob/master/src/flags.ts
  28. chromeFlags: Array<string>;
  29. // (optional) Close the Chrome process on `Ctrl-C`
  30. // Default: true
  31. handleSIGINT: boolean;
  32. // (optional) Explicit path of intended Chrome binary
  33.  // * If this `chromePath` option is defined, it will be used.
  34. // * Otherwise, the `CHROME_PATH` env variable will be used if set. (`LIGHTHOUSE_CHROMIUM_PATH` is deprecated)
  35.  // * Otherwise, a detected Chrome Canary will be used if found
  36. // * Otherwise, a detected Chrome (stable) will be used
  37. chromePath: string;
  38. // (optional) Chrome profile path to use, if set to `false` then the default profile will be used.
  39. // By default, a fresh Chrome profile will be created
  40. userDataDir: string | boolean;
  41. // (optional) Starting URL to open the browser with
  42. // Default: `about:blank`
  43. startingUrl: string;
  44. // (optional) Logging level
  45. // Default: 'silent'
  46. logLevel: 'verbose'|'info'|'error'|'silent';
  47. // (optional) Flags specific in [flags.ts](src/flags.ts) will not be included.
  48. // Typically used with the defaultFlags() method and chromeFlags option.
  49. // Default: false
  50. ignoreDefaultFlags: boolean;
  51. // (optional) Interval in ms, which defines how often launcher checks browser port to be ready.
  52. // Default: 500
  53. connectionPollInterval: number;
  54. // (optional) A number of retries, before browser launch considered unsuccessful.
  55. // Default: 50
  56. maxConnectionRetries: number;
  57. // (optional) A dict of environmental key value pairs to pass to the spawned chrome process.
  58. envVars: {[key: string]: string};
  59. };
  60. ```
  61. #### Launched chrome interface
  62. #### `.launch().then(chrome => ...`
  63. ```js
  64. // The remote debugging port exposed by the launched chrome
  65. chrome.port: number;
  66. // Method to kill Chrome (and cleanup the profile folder)
  67. chrome.kill: () => Promise<{}>;
  68. // The process id
  69. chrome.pid: number;
  70. // The childProcess object for the launched Chrome
  71. chrome.process: childProcess
  72. ```
  73. ### `ChromeLauncher.Launcher.defaultFlags()`
  74. Returns an `Array<string>` of the default [flags](docs/chrome-flags-for-tools.md) Chrome is launched with. Typically used along with the `ignoreDefaultFlags` and `chromeFlags` options.
  75. Note: This array will exclude the following flags: `--remote-debugging-port` `--disable-setuid-sandbox` `--user-data-dir`.
  76. ### `ChromeLauncher.getInstallations()`
  77. Returns an `Array<string>` of paths to available Chrome installations. When `chromePath` is not provided to `.launch()`, the first installation returned from this method is used instead.
  78. Note: This method performs synchronous I/O operations.
  79. ### `.killAll()`
  80. Attempts to kill all Chrome instances created with [`.launch([opts])`](#launchopts). Returns a Promise that resolves to an array of errors that occurred while killing instances. If all instances were killed successfully, the array will be empty.
  81. ```js
  82. const ChromeLauncher = require('chrome-launcher');
  83. async function cleanup() {
  84. await ChromeLauncher.killAll();
  85. }
  86. ```
  87. ## Examples
  88. #### Launching chrome:
  89. ```js
  90. const ChromeLauncher = require('chrome-launcher');
  91. ChromeLauncher.launch({
  92. startingUrl: 'https://google.com'
  93. }).then(chrome => {
  94. console.log(`Chrome debugging port running on ${chrome.port}`);
  95. });
  96. ```
  97. #### Launching headless chrome:
  98. ```js
  99. const ChromeLauncher = require('chrome-launcher');
  100. ChromeLauncher.launch({
  101. startingUrl: 'https://google.com',
  102. chromeFlags: ['--headless', '--disable-gpu']
  103. }).then(chrome => {
  104. console.log(`Chrome debugging port running on ${chrome.port}`);
  105. });
  106. ```
  107. #### Launching with support for extensions and audio:
  108. ```js
  109. const ChromeLauncher = require('chrome-launcher');
  110. const newFlags = ChromeLauncher.Launcher.defaultFlags().filter(flag => flag !== '--disable-extensions' && flag !== '--mute-audio');
  111. ChromeLauncher.launch({
  112. ignoreDefaultFlags: true,
  113. chromeFlags: newFlags,
  114. }).then(chrome => { ... });
  115. ```
  116. ### Continuous Integration
  117. In a CI environment like Travis, Chrome may not be installed. If you want to use `chrome-launcher`, Travis can [install Chrome at run time with an addon](https://docs.travis-ci.com/user/chrome). Alternatively, you can also install Chrome using the [`download-chrome.sh`](https://raw.githubusercontent.com/GoogleChrome/chrome-launcher/v0.8.0/scripts/download-chrome.sh) script.
  118. Then in `.travis.yml`, use it like so:
  119. ```yaml
  120. language: node_js
  121. install:
  122. - yarn install
  123. before_script:
  124. - export DISPLAY=:99.0
  125. - export CHROME_PATH="$(pwd)/chrome-linux/chrome"
  126. - sh -e /etc/init.d/xvfb start
  127. - sleep 3 # wait for xvfb to boot
  128. addons:
  129. chrome: stable
  130. ```