How to use logPolitely method in Puppeteer

Best JavaScript code snippet using puppeteer

Run Puppeteer automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

install.js

Source: install.js Github

copy
1/**
2 * Copyright 2017 Google Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/**
18 * This file is part of public API.
19 *
20 * By default, the `puppeteer` package runs this script during the installation
21 * process unless one of the env flags is provided.
22 * `puppeteer-core` package doesn't include this step at all. However, it's
23 * still possible to install a supported browser using this script when
24 * necessary.
25 */
26
27const compileTypeScriptIfRequired = require('./typescript-if-required');
28
29async function download() {
30  await compileTypeScriptIfRequired();
31  // need to ensure TS is compiled before loading the installer
32  const {
33    downloadBrowser,
34    logPolitely,
35  } = require('./lib/cjs/puppeteer/node/install');
36
37  if (process.env.PUPPETEER_SKIP_DOWNLOAD) {
38    logPolitely(
39      '**INFO** Skipping browser download. "PUPPETEER_SKIP_DOWNLOAD" environment variable was found.'
40    );
41    return;
42  }
43  if (
44    process.env.NPM_CONFIG_PUPPETEER_SKIP_DOWNLOAD ||
45    process.env.npm_config_puppeteer_skip_download
46  ) {
47    logPolitely(
48      '**INFO** Skipping browser download. "PUPPETEER_SKIP_DOWNLOAD" was set in npm config.'
49    );
50    return;
51  }
52  if (
53    process.env.NPM_PACKAGE_CONFIG_PUPPETEER_SKIP_DOWNLOAD ||
54    process.env.npm_package_config_puppeteer_skip_download
55  ) {
56    logPolitely(
57      '**INFO** Skipping browser download. "PUPPETEER_SKIP_DOWNLOAD" was set in project config.'
58    );
59    return;
60  }
61  if (process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD) {
62    logPolitely(
63      '**INFO** Skipping browser download. "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" environment variable was found.'
64    );
65    return;
66  }
67  if (
68    process.env.NPM_CONFIG_PUPPETEER_SKIP_CHROMIUM_DOWNLOAD ||
69    process.env.npm_config_puppeteer_skip_chromium_download
70  ) {
71    logPolitely(
72      '**INFO** Skipping browser download. "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" was set in npm config.'
73    );
74    return;
75  }
76  if (
77    process.env.NPM_PACKAGE_CONFIG_PUPPETEER_SKIP_CHROMIUM_DOWNLOAD ||
78    process.env.npm_package_config_puppeteer_skip_chromium_download
79  ) {
80    logPolitely(
81      '**INFO** Skipping browser download. "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" was set in project config.'
82    );
83    return;
84  }
85
86  downloadBrowser();
87}
88
89download();
90
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Puppeteer on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)