How to use resolveExecutablePath method in Puppeteer

Best JavaScript code snippet using puppeteer

Launcher.js

Source:Launcher.js Github

copy

Full Screen

...52 if (os.arch() === 'arm64') {53 chromeExecutable = '/usr/bin/chromium-browser';54 }55 else if (!executablePath) {56 const { missingText, executablePath } = resolveExecutablePath(this);57 if (missingText)58 throw new Error(missingText);59 chromeExecutable = executablePath;60 }61 const usePipe = chromeArguments.includes('--remote-debugging-pipe');62 const runner = new BrowserRunner(chromeExecutable, chromeArguments, temporaryUserDataDir);63 runner.start({64 handleSIGHUP,65 handleSIGTERM,66 handleSIGINT,67 dumpio,68 env,69 pipe: usePipe,70 });71 try {72 const connection = await runner.setupConnection({73 usePipe,74 timeout,75 slowMo,76 preferredRevision: this._preferredRevision,77 });78 const browser = await Browser.create(connection, [], ignoreHTTPSErrors, defaultViewport, runner.proc, runner.close.bind(runner));79 await browser.waitForTarget((t) => t.type() === 'page');80 return browser;81 }82 catch (error) {83 runner.kill();84 throw error;85 }86 }87 /**88 * @param {!Launcher.ChromeArgOptions=} options89 * @returns {!Array<string>}90 */91 defaultArgs(options = {}) {92 const chromeArguments = [93 '--disable-background-networking',94 '--enable-features=NetworkService,NetworkServiceInProcess',95 '--disable-background-timer-throttling',96 '--disable-backgrounding-occluded-windows',97 '--disable-breakpad',98 '--disable-client-side-phishing-detection',99 '--disable-component-extensions-with-background-pages',100 '--disable-default-apps',101 '--disable-dev-shm-usage',102 '--disable-extensions',103 '--disable-features=TranslateUI',104 '--disable-hang-monitor',105 '--disable-ipc-flooding-protection',106 '--disable-popup-blocking',107 '--disable-prompt-on-repost',108 '--disable-renderer-backgrounding',109 '--disable-sync',110 '--force-color-profile=srgb',111 '--metrics-recording-only',112 '--no-first-run',113 '--enable-automation',114 '--password-store=basic',115 '--use-mock-keychain',116 // TODO(sadym): remove '--enable-blink-features=IdleDetection'117 // once IdleDetection is turned on by default.118 '--enable-blink-features=IdleDetection',119 ];120 const { devtools = false, headless = !devtools, args = [], userDataDir = null, } = options;121 if (userDataDir)122 chromeArguments.push(`--user-data-dir=${path.resolve(userDataDir)}`);123 if (devtools)124 chromeArguments.push('--auto-open-devtools-for-tabs');125 if (headless) {126 chromeArguments.push('--headless', '--hide-scrollbars', '--mute-audio');127 }128 if (args.every((arg) => arg.startsWith('-')))129 chromeArguments.push('about:blank');130 chromeArguments.push(...args);131 return chromeArguments;132 }133 executablePath() {134 return resolveExecutablePath(this).executablePath;135 }136 get product() {137 return 'chrome';138 }139}140/**141 * @internal142 */143class FirefoxLauncher {144 constructor(projectRoot, preferredRevision, isPuppeteerCore) {145 this._projectRoot = projectRoot;146 this._preferredRevision = preferredRevision;147 this._isPuppeteerCore = isPuppeteerCore;148 }149 async launch(options = {}) {150 const { ignoreDefaultArgs = false, args = [], dumpio = false, executablePath = null, pipe = false, env = process.env, handleSIGINT = true, handleSIGTERM = true, handleSIGHUP = true, ignoreHTTPSErrors = false, defaultViewport = { width: 800, height: 600 }, slowMo = 0, timeout = 30000, extraPrefsFirefox = {}, } = options;151 const firefoxArguments = [];152 if (!ignoreDefaultArgs)153 firefoxArguments.push(...this.defaultArgs(options));154 else if (Array.isArray(ignoreDefaultArgs))155 firefoxArguments.push(...this.defaultArgs(options).filter((arg) => !ignoreDefaultArgs.includes(arg)));156 else157 firefoxArguments.push(...args);158 if (!firefoxArguments.some((argument) => argument.startsWith('--remote-debugging-')))159 firefoxArguments.push('--remote-debugging-port=0');160 let temporaryUserDataDir = null;161 if (!firefoxArguments.includes('-profile') &&162 !firefoxArguments.includes('--profile')) {163 temporaryUserDataDir = await this._createProfile(extraPrefsFirefox);164 firefoxArguments.push('--profile');165 firefoxArguments.push(temporaryUserDataDir);166 }167 await this._updateRevision();168 let firefoxExecutable = executablePath;169 if (!executablePath) {170 const { missingText, executablePath } = resolveExecutablePath(this);171 if (missingText)172 throw new Error(missingText);173 firefoxExecutable = executablePath;174 }175 const runner = new BrowserRunner(firefoxExecutable, firefoxArguments, temporaryUserDataDir);176 runner.start({177 handleSIGHUP,178 handleSIGTERM,179 handleSIGINT,180 dumpio,181 env,182 pipe,183 });184 try {185 const connection = await runner.setupConnection({186 usePipe: pipe,187 timeout,188 slowMo,189 preferredRevision: this._preferredRevision,190 });191 const browser = await Browser.create(connection, [], ignoreHTTPSErrors, defaultViewport, runner.proc, runner.close.bind(runner));192 await browser.waitForTarget((t) => t.type() === 'page');193 return browser;194 }195 catch (error) {196 runner.kill();197 throw error;198 }199 }200 executablePath() {201 return resolveExecutablePath(this).executablePath;202 }203 async _updateRevision() {204 // replace 'latest' placeholder with actual downloaded revision205 if (this._preferredRevision === 'latest') {206 const browserFetcher = new BrowserFetcher(this._projectRoot, {207 product: this.product,208 });209 const localRevisions = await browserFetcher.localRevisions();210 if (localRevisions[0])211 this._preferredRevision = localRevisions[0];212 }213 }214 get product() {215 return 'firefox';216 }217 defaultArgs(options = {}) {218 const firefoxArguments = ['--no-remote', '--foreground'];219 if (os.platform().startsWith('win')) {220 firefoxArguments.push('--wait-for-browser');221 }222 const { devtools = false, headless = !devtools, args = [], userDataDir = null, } = options;223 if (userDataDir) {224 firefoxArguments.push('--profile');225 firefoxArguments.push(userDataDir);226 }227 if (headless)228 firefoxArguments.push('--headless');229 if (devtools)230 firefoxArguments.push('--devtools');231 if (args.every((arg) => arg.startsWith('-')))232 firefoxArguments.push('about:blank');233 firefoxArguments.push(...args);234 return firefoxArguments;235 }236 async _createProfile(extraPrefs) {237 const profilePath = await mkdtempAsync(path.join(os.tmpdir(), 'puppeteer_dev_firefox_profile-'));238 const prefsJS = [];239 const userJS = [];240 const server = 'dummy.test';241 const defaultPreferences = {242 // Make sure Shield doesn't hit the network.243 'app.normandy.api_url': '',244 // Disable Firefox old build background check245 'app.update.checkInstallTime': false,246 // Disable automatically upgrading Firefox247 'app.update.disabledForTesting': true,248 // Increase the APZ content response timeout to 1 minute249 'apz.content_response_timeout': 60000,250 // Prevent various error message on the console251 // jest-puppeteer asserts that no error message is emitted by the console252 'browser.contentblocking.features.standard': '-tp,tpPrivate,cookieBehavior0,-cm,-fp',253 // Enable the dump function: which sends messages to the system254 // console255 // https://bugzilla.mozilla.org/show_bug.cgi?id=1543115256 'browser.dom.window.dump.enabled': true,257 // Disable topstories258 'browser.newtabpage.activity-stream.feeds.system.topstories': false,259 // Always display a blank page260 'browser.newtabpage.enabled': false,261 // Background thumbnails in particular cause grief: and disabling262 // thumbnails in general cannot hurt263 'browser.pagethumbnails.capturing_disabled': true,264 // Disable safebrowsing components.265 'browser.safebrowsing.blockedURIs.enabled': false,266 'browser.safebrowsing.downloads.enabled': false,267 'browser.safebrowsing.malware.enabled': false,268 'browser.safebrowsing.passwords.enabled': false,269 'browser.safebrowsing.phishing.enabled': false,270 // Disable updates to search engines.271 'browser.search.update': false,272 // Do not restore the last open set of tabs if the browser has crashed273 'browser.sessionstore.resume_from_crash': false,274 // Skip check for default browser on startup275 'browser.shell.checkDefaultBrowser': false,276 // Disable newtabpage277 'browser.startup.homepage': 'about:blank',278 // Do not redirect user when a milstone upgrade of Firefox is detected279 'browser.startup.homepage_override.mstone': 'ignore',280 // Start with a blank page about:blank281 'browser.startup.page': 0,282 // Do not allow background tabs to be zombified on Android: otherwise for283 // tests that open additional tabs: the test harness tab itself might get284 // unloaded285 'browser.tabs.disableBackgroundZombification': false,286 // Do not warn when closing all other open tabs287 'browser.tabs.warnOnCloseOtherTabs': false,288 // Do not warn when multiple tabs will be opened289 'browser.tabs.warnOnOpen': false,290 // Disable the UI tour.291 'browser.uitour.enabled': false,292 // Turn off search suggestions in the location bar so as not to trigger293 // network connections.294 'browser.urlbar.suggest.searches': false,295 // Disable first run splash page on Windows 10296 'browser.usedOnWindows10.introURL': '',297 // Do not warn on quitting Firefox298 'browser.warnOnQuit': false,299 // Defensively disable data reporting systems300 'datareporting.healthreport.documentServerURI': `http://${server}/dummy/healthreport/`,301 'datareporting.healthreport.logging.consoleEnabled': false,302 'datareporting.healthreport.service.enabled': false,303 'datareporting.healthreport.service.firstRun': false,304 'datareporting.healthreport.uploadEnabled': false,305 // Do not show datareporting policy notifications which can interfere with tests306 'datareporting.policy.dataSubmissionEnabled': false,307 'datareporting.policy.dataSubmissionPolicyBypassNotification': true,308 // DevTools JSONViewer sometimes fails to load dependencies with its require.js.309 // This doesn't affect Puppeteer but spams console (Bug 1424372)310 'devtools.jsonview.enabled': false,311 // Disable popup-blocker312 'dom.disable_open_during_load': false,313 // Enable the support for File object creation in the content process314 // Required for |Page.setFileInputFiles| protocol method.315 'dom.file.createInChild': true,316 // Disable the ProcessHangMonitor317 'dom.ipc.reportProcessHangs': false,318 // Disable slow script dialogues319 'dom.max_chrome_script_run_time': 0,320 'dom.max_script_run_time': 0,321 // Only load extensions from the application and user profile322 // AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_APPLICATION323 'extensions.autoDisableScopes': 0,324 'extensions.enabledScopes': 5,325 // Disable metadata caching for installed add-ons by default326 'extensions.getAddons.cache.enabled': false,327 // Disable installing any distribution extensions or add-ons.328 'extensions.installDistroAddons': false,329 // Disabled screenshots extension330 'extensions.screenshots.disabled': true,331 // Turn off extension updates so they do not bother tests332 'extensions.update.enabled': false,333 // Turn off extension updates so they do not bother tests334 'extensions.update.notifyUser': false,335 // Make sure opening about:addons will not hit the network336 'extensions.webservice.discoverURL': `http://${server}/dummy/discoveryURL`,337 // Allow the application to have focus even it runs in the background338 'focusmanager.testmode': true,339 // Disable useragent updates340 'general.useragent.updates.enabled': false,341 // Always use network provider for geolocation tests so we bypass the342 // macOS dialog raised by the corelocation provider343 'geo.provider.testing': true,344 // Do not scan Wifi345 'geo.wifi.scan': false,346 // No hang monitor347 'hangmonitor.timeout': 0,348 // Show chrome errors and warnings in the error console349 'javascript.options.showInConsole': true,350 // Disable download and usage of OpenH264: and Widevine plugins351 'media.gmp-manager.updateEnabled': false,352 // Prevent various error message on the console353 // jest-puppeteer asserts that no error message is emitted by the console354 'network.cookie.cookieBehavior': 0,355 // Do not prompt for temporary redirects356 'network.http.prompt-temp-redirect': false,357 // Disable speculative connections so they are not reported as leaking358 // when they are hanging around359 'network.http.speculative-parallel-limit': 0,360 // Do not automatically switch between offline and online361 'network.manage-offline-status': false,362 // Make sure SNTP requests do not hit the network363 'network.sntp.pools': server,364 // Disable Flash.365 'plugin.state.flash': 0,366 'privacy.trackingprotection.enabled': false,367 // Enable Remote Agent368 // https://bugzilla.mozilla.org/show_bug.cgi?id=1544393369 'remote.enabled': true,370 // Don't do network connections for mitm priming371 'security.certerrors.mitm.priming.enabled': false,372 // Local documents have access to all other local documents,373 // including directory listings374 'security.fileuri.strict_origin_policy': false,375 // Do not wait for the notification button security delay376 'security.notification_enable_delay': 0,377 // Ensure blocklist updates do not hit the network378 'services.settings.server': `http://${server}/dummy/blocklist/`,379 // Do not automatically fill sign-in forms with known usernames and380 // passwords381 'signon.autofillForms': false,382 // Disable password capture, so that tests that include forms are not383 // influenced by the presence of the persistent doorhanger notification384 'signon.rememberSignons': false,385 // Disable first-run welcome page386 'startup.homepage_welcome_url': 'about:blank',387 // Disable first-run welcome page388 'startup.homepage_welcome_url.additional': '',389 // Disable browser animations (tabs, fullscreen, sliding alerts)390 'toolkit.cosmeticAnimations.enabled': false,391 // Prevent starting into safe mode after application crashes392 'toolkit.startup.max_resumed_crashes': -1,393 };394 Object.assign(defaultPreferences, extraPrefs);395 for (const [key, value] of Object.entries(defaultPreferences))396 userJS.push(`user_pref(${JSON.stringify(key)}, ${JSON.stringify(value)});`);397 await writeFileAsync(path.join(profilePath, 'user.js'), userJS.join('\n'));398 await writeFileAsync(path.join(profilePath, 'prefs.js'), prefsJS.join('\n'));399 return profilePath;400 }401}402function resolveExecutablePath(launcher) {403 let downloadPath;404 // puppeteer-core doesn't take into account PUPPETEER_* env variables.405 if (!launcher._isPuppeteerCore) {406 const executablePath = process.env.PUPPETEER_EXECUTABLE_PATH ||407 process.env.npm_config_puppeteer_executable_path ||408 process.env.npm_package_config_puppeteer_executable_path;409 if (executablePath) {410 const missingText = !fs.existsSync(executablePath)411 ? 'Tried to use PUPPETEER_EXECUTABLE_PATH env variable to launch browser but did not find any executable at: ' +412 executablePath413 : null;414 return { executablePath, missingText };415 }416 downloadPath =...

Full Screen

Full Screen

ios-specs.js

Source:ios-specs.js Github

copy

Full Screen

1// transpile:mocha2import { fixes, XcodeCheck, XcodeCmdLineToolsCheck, DevToolsSecurityCheck,3 AuthorizationDbCheck, CarthageCheck, OptionalApplesimutilsCommandCheck,4 OptionalIdbCommandCheck, OptionalIOSDeployCommandCheck,5 OptionalLyftCommandCheck } from '../lib/ios';6import { fs, system } from 'appium-support';7import * as utils from '../lib/utils';8import * as tp from 'teen_process';9import * as prompter from '../lib/prompt';10import CarthageDetector from '../lib/carthage-detector';11import FixSkippedError from '../lib/doctor';12import log from '../lib/logger';13import chai from 'chai';14import chaiAsPromised from 'chai-as-promised';15import B from 'bluebird';16import { withMocks, withSandbox, stubLog } from 'appium-test-support';17import {removeColors} from './helper';18chai.should();19chai.use(chaiAsPromised);20describe('ios', function () {21 describe('XcodeCheck', withMocks({tp, fs}, (mocks) => {22 let check = new XcodeCheck();23 it('autofix', function () {24 check.autofix.should.not.be.ok;25 });26 it('diagnose - success', async function () {27 // xcrun28 mocks.tp.expects('exec').once().returns(29 B.resolve({stdout: 'usage: simctl [--set <path>] [--profiles <path>] <subcommand> ...', stderr: ''}));30 // xcode-select31 mocks.tp.expects('exec').once().returns(32 B.resolve({stdout: '/a/b/c/d\n', stderr: ''}));33 mocks.fs.expects('exists').once().returns(B.resolve(true));34 (await check.diagnose()).should.deep.equal({35 ok: true,36 optional: false,37 message: 'Xcode is installed at: /a/b/c/d'38 });39 mocks.verify();40 });41 it('diagnose - failure - xcode-select', async function () {42 // xcrun43 mocks.tp.expects('exec').once().returns(44 B.resolve({stdout: 'usage: simctl [--set <path>] [--profiles <path>] <subcommand> ...', stderr: ''}));45 // xcode-select46 mocks.tp.expects('exec').once().returns(B.reject(new Error('Something wrong!')));47 (await check.diagnose()).should.deep.equal({48 ok: false,49 optional: false,50 message: 'Xcode is NOT installed!'51 });52 mocks.verify();53 });54 it('diagnose - failure - path not exists', async function () {55 // xcrun56 mocks.tp.expects('exec').once().returns(57 B.resolve({stdout: 'usage: simctl [--set <path>] [--profiles <path>] <subcommand> ...', stderr: ''}));58 // xcode-select59 mocks.tp.expects('exec').once().returns(60 B.resolve({stdout: '/a/b/c/d\n', stderr: ''}));61 mocks.fs.expects('exists').once().returns(B.resolve(false));62 (await check.diagnose()).should.deep.equal({63 ok: false,64 optional: false,65 message: 'Xcode cannot be found at \'/a/b/c/d\'!'66 });67 mocks.verify();68 });69 it('diagnose - failure - xcrun does not work', async function () {70 // xcrun71 mocks.tp.expects('exec').once().returns(B.reject(new Error('xcrun: error: unable to find utility "simctl", not a developer tool or in PATH')));72 // no xcode-select73 (await check.diagnose()).should.deep.equal({74 ok: false,75 optional: false,76 message: 'Error running xcrun simctl'77 });78 mocks.verify();79 });80 it('fix', async function () {81 removeColors(await check.fix()).should.equal("Manually install Xcode, and make sure 'xcode-select -p' command shows proper path like '/Applications/Xcode.app/Contents/Developer'");82 });83 }));84 describe('XcodeCmdLineToolsCheck', withSandbox({mocks: {tp, utils, prompter, system}}, (S) => {85 let check = new XcodeCmdLineToolsCheck();86 it('autofix', function () {87 check.autofix.should.be.ok;88 });89 it('diagnose - success', async function () {90 S.mocks.tp.expects('exec').once().returns(91 B.resolve({stdout: '/Applications/Xcode.app/Contents/Developer\n', stderr: ''}));92 (await check.diagnose()).should.deep.equal({93 ok: true,94 optional: false,95 message: 'Xcode Command Line Tools are installed in: /Applications/Xcode.app/Contents/Developer'96 });97 S.verify();98 });99 it('diagnose - failure - pkgutil crash', async function () {100 S.mocks.tp.expects('exec').once().throws(new Error('Something wrong!'));101 (await check.diagnose()).should.deep.equal({102 ok: false,103 optional: false,104 message: 'Xcode Command Line Tools are NOT installed!'105 });106 S.verify();107 });108 it('diagnose - failure - xcode-select -p returns status 2', async function () {109 S.mocks.tp.expects('exec').once().throws(new Error());110 (await check.diagnose()).should.deep.equal({111 ok: false,112 optional: false,113 message: 'Xcode Command Line Tools are NOT installed!'114 });115 S.verify();116 });117 it('fix - yes', async function () {118 let logStub = stubLog(S.sandbox, log, {stripColors: true});119 S.mocks.tp.expects('exec').once().returns(120 B.resolve({stdout: '', stderr: ''}));121 S.mocks.prompter.expects('fixIt').once().returns(B.resolve('yes'));122 await check.fix();123 S.verify();124 logStub.output.should.equal([125 'info: The following command need be executed: xcode-select --install',126 ].join('\n'));127 });128 it('fix - no', async function () {129 let logStub = stubLog(S.sandbox, log, {stripColors: true});130 S.mocks.tp.expects('exec').never();131 S.mocks.prompter.expects('fixIt').once().returns(B.resolve('no'));132 await check.fix().should.be.rejectedWith(FixSkippedError);133 S.verify();134 logStub.output.should.equal([135 'info: The following command need be executed: xcode-select --install',136 'info: Skipping you will need to install Xcode manually.'137 ].join('\n'));138 });139 }));140 describe('authorizeIosFix', withSandbox({mocks: {utils, prompter}}, (S) => {141 it('fix - yes', async function () {142 let logStub = stubLog(S.sandbox, log, {stripColors: true});143 S.mocks.utils.expects('authorizeIos').once();144 S.mocks.prompter.expects('fixIt').once().returns(B.resolve('yes'));145 await fixes.authorizeIosFix();146 S.verify();147 logStub.output.should.equal([148 'info: The authorize iOS script need to be run.',149 ].join('\n'));150 });151 it('fix - no', async function () {152 let logStub = stubLog(S.sandbox, log, {stripColors: true});153 S.mocks.utils.expects('authorizeIos').never();154 S.mocks.prompter.expects('fixIt').once().returns(B.resolve('no'));155 await fixes.authorizeIosFix().should.be.rejectedWith(FixSkippedError);156 S.verify();157 logStub.output.should.equal([158 'info: The authorize iOS script need to be run.',159 'info: Skipping you will need to run the authorize iOS manually.'160 ].join('\n'));161 });162 }));163 describe('DevToolsSecurityCheck', withMocks({fixes, tp}, (mocks) => {164 let check = new DevToolsSecurityCheck();165 it('autofix', function () {166 check.autofix.should.be.ok;167 });168 it('diagnose - success', async function () {169 mocks.tp.expects('exec').once().returns(170 B.resolve({stdout: '1234 enabled\n', stderr: ''}));171 (await check.diagnose()).should.deep.equal({172 ok: true,173 optional: false,174 message: 'DevToolsSecurity is enabled.'175 });176 mocks.verify();177 });178 it('diagnose - failure - DevToolsSecurity crash', async function () {179 mocks.tp.expects('exec').once().returns(B.reject(new Error('Something wrong!')));180 (await check.diagnose()).should.deep.equal({181 ok: false,182 optional: false,183 message: 'DevToolsSecurity is NOT enabled!'184 });185 mocks.verify();186 });187 it('diagnose - failure - not enabled', async function () {188 mocks.tp.expects('exec').once().returns(189 B.resolve({stdout: '1234 abcd\n', stderr: ''}));190 (await check.diagnose()).should.deep.equal({191 ok: false,192 optional: false,193 message: 'DevToolsSecurity is NOT enabled!'194 });195 mocks.verify();196 });197 it('fix', async function () {198 mocks.fixes.expects('authorizeIosFix').once();199 await check.fix();200 mocks.verify();201 });202 }));203 describe('AuthorizationDbCheck', withMocks({fixes, tp, fs, utils, system}, (mocks) => {204 let check = new AuthorizationDbCheck();205 it('autofix', function () {206 check.autofix.should.be.ok;207 });208 it('diagnose - success', async function () {209 mocks.tp.expects('exec').once().returns(210 B.resolve({stdout: '1234 is-developer\n', stderr: ''}));211 (await check.diagnose()).should.deep.equal({212 ok: true,213 optional: false,214 message: 'The Authorization DB is set up properly.'215 });216 mocks.verify();217 });218 it('diagnose - failure', async function () {219 mocks.tp.expects('exec').once().returns(B.reject(new Error('Oh No!')));220 (await check.diagnose()).should.deep.equal({221 ok: false,222 optional: false,223 message: 'The Authorization DB is NOT set up properly.'224 });225 mocks.verify();226 });227 it('fix', async function () {228 mocks.fixes.expects('authorizeIosFix').once();229 await check.fix();230 mocks.verify();231 });232 }));233 describe('CarthageCheck', withMocks({CarthageDetector, tp}, (mocks) => {234 let check = new CarthageCheck();235 it('autofix', function () {236 check.autofix.should.not.be.ok;237 });238 it('diagnose - success', async function () {239 mocks.CarthageDetector.expects('detect').once().returns(B.resolve('/usr/local/bin/carthage'));240 mocks.tp.expects('exec').once().returns(241 B.resolve({stdout: 'Please update to the latest Carthage version: 0.33.0. You currently are on 0.32.0\n0.32.0\n', stderr: ''}));242 (await check.diagnose()).should.deep.equal({243 ok: true,244 optional: false,245 message: 'Carthage was found at: /usr/local/bin/carthage. Installed version is: 0.32.0'246 });247 mocks.verify();248 });249 it('diagnose - success - one line carthage version', async function () {250 mocks.CarthageDetector.expects('detect').once().returns(B.resolve('/usr/local/bin/carthage'));251 mocks.tp.expects('exec').once().returns(252 B.resolve({stdout: '0.32.0\n', stderr: ''}));253 (await check.diagnose()).should.deep.equal({254 ok: true,255 optional: false,256 message: 'Carthage was found at: /usr/local/bin/carthage. Installed version is: 0.32.0'257 });258 mocks.verify();259 });260 it('diagnose - success - but error happens', async function () {261 mocks.CarthageDetector.expects('detect').once().returns(B.resolve('/usr/local/bin/carthage'));262 mocks.tp.expects('exec').once().throws(new Error());263 (await check.diagnose()).should.deep.equal({264 ok: true,265 optional: false,266 message: 'Carthage was found at: /usr/local/bin/carthage'267 });268 mocks.verify();269 });270 it('diagnose - failure', async function () {271 mocks.CarthageDetector.expects('detect').once().returns(B.resolve(null));272 (await check.diagnose()).should.deep.equal({273 ok: false,274 optional: false,275 message: 'Carthage was NOT found!'276 });277 mocks.verify();278 });279 it('fix', async function () {280 removeColors(await check.fix()).should.equal('[For lower than Appium 1.20.0] Please install Carthage. Visit https://github.com/Carthage/Carthage#installing-carthage for more information.');281 });282 }));283 describe('OptionalLyftCommandCheck', withMocks({tp, utils}, (mocks) => {284 let check = new OptionalLyftCommandCheck();285 it('autofix', function () {286 check.autofix.should.not.be.ok;287 });288 it('diagnose - success', async function () {289 mocks.utils.expects('resolveExecutablePath').once().returns('path/to/set-simulator-location');290 (await check.diagnose()).should.deep.equal({291 ok: true,292 optional: true,293 message: 'set-simulator-location is installed'294 });295 mocks.verify();296 });297 it('diagnose - failure', async function () {298 mocks.utils.expects('resolveExecutablePath').once().returns(false);299 (await check.diagnose()).should.deep.equal({300 ok: false,301 optional: true,302 message: 'set-simulator-location is not installed'303 });304 mocks.verify();305 });306 it('fix', async function () {307 removeColors(await check.fix()).should.equal('set-simulator-location is needed to set location for Simulator. ' +308 'Please read https://github.com/lyft/set-simulator-location to install it');309 });310 }));311 describe('OptionalIdbCommandCheck', withMocks({tp, utils}, (mocks) => {312 let check = new OptionalIdbCommandCheck();313 it('autofix', function () {314 check.autofix.should.not.be.ok;315 });316 it('diagnose - success', async function () {317 mocks.utils.expects('resolveExecutablePath').once().returns('path/to/idb');318 mocks.utils.expects('resolveExecutablePath').once().returns('path/to/idb_cpmpanion');319 (await check.diagnose()).should.deep.equal({320 ok: true,321 optional: true,322 message: 'idb and idb_companion are installed'323 });324 mocks.verify();325 });326 it('diagnose - failure because of no idb_companion and idb', async function () {327 mocks.utils.expects('resolveExecutablePath').once().returns(false);328 mocks.utils.expects('resolveExecutablePath').once().returns(false);329 (await check.diagnose()).should.deep.equal({330 ok: false,331 optional: true,332 message: 'idb and idb_companion are not installed'333 });334 mocks.verify();335 });336 it('diagnose - failure because of no idb_companion', async function () {337 mocks.utils.expects('resolveExecutablePath').once().returns('path/to/idb');338 mocks.utils.expects('resolveExecutablePath').once().returns(false);339 (await check.diagnose()).should.deep.equal({340 ok: false,341 optional: true,342 message: 'idb_companion is not installed'343 });344 mocks.verify();345 });346 it('diagnose - failure because of no idb', async function () {347 mocks.utils.expects('resolveExecutablePath').once().returns(false);348 mocks.utils.expects('resolveExecutablePath').once().returns('path/to/idb_cpmpanion');349 (await check.diagnose()).should.deep.equal({350 ok: false,351 optional: true,352 message: 'idb is not installed'353 });354 mocks.verify();355 });356 it('fix', async function () {357 removeColors(await check.fix()).should.equal('Why idb is needed and how to install it: https://github.com/appium/appium-idb');358 });359 }));360 describe('OptionalApplesimutilsCommandCheck', withMocks({tp, utils}, (mocks) => {361 let check = new OptionalApplesimutilsCommandCheck();362 it('autofix', function () {363 check.autofix.should.not.be.ok;364 });365 it('diagnose - success', async function () {366 mocks.utils.expects('resolveExecutablePath').once().returns('path/to/applesimutils');367 mocks.tp.expects('exec').once().returns({stdout: 'vxx.xx.xx', stderr: ''});368 (await check.diagnose()).should.deep.equal({369 ok: true,370 optional: true,371 message: 'applesimutils is installed at: path/to/applesimutils. Installed versions are: vxx.xx.xx'372 });373 mocks.verify();374 });375 it('diagnose - failure', async function () {376 mocks.utils.expects('resolveExecutablePath').once().returns(false);377 (await check.diagnose()).should.deep.equal({378 ok: false,379 optional: true,380 message: 'applesimutils cannot be found'381 });382 mocks.verify();383 });384 it('fix', async function () {385 removeColors(await check.fix()).should.equal('Why applesimutils is needed and how to install it: http://appium.io/docs/en/drivers/ios-xcuitest/');386 });387 }));388 describe('OptionalIOSDeployCommandCheck', withMocks({tp, utils}, (mocks) => {389 let check = new OptionalIOSDeployCommandCheck();390 it('autofix', function () {391 check.autofix.should.not.be.ok;392 });393 it('diagnose - success', async function () {394 mocks.utils.expects('resolveExecutablePath').once().returns('path/to/ios-deploy');395 mocks.tp.expects('exec').once().returns({stdout: '1.9.4', stderr: ''});396 (await check.diagnose()).should.deep.equal({397 ok: true,398 optional: true,399 message: 'ios-deploy is installed at: path/to/ios-deploy. Installed version is: 1.9.4'400 });401 mocks.verify();402 });403 it('diagnose - failure', async function () {404 mocks.utils.expects('resolveExecutablePath').once().returns(false);405 (await check.diagnose()).should.deep.equal({406 ok: false,407 optional: true,408 message: 'ios-deploy cannot be found'409 });410 mocks.verify();411 });412 it('fix', async function () {413 removeColors(await check.fix()).should.equal('ios-deploy is used as a fallback command to install iOS applications to real device. Please read https://github.com/ios-control/ios-deploy/ to install it');414 });415 }));...

Full Screen

Full Screen

ios.js

Source:ios.js Github

copy

Full Screen

...148checks.push(new CarthageCheck());149checks.push(new EnvVarAndPathCheck('HOME'));150class OptionalLyftCommandCheck extends DoctorCheck {151 async diagnose () {152 const lyftCmd = await resolveExecutablePath('set-simulator-location');153 if (lyftCmd) {154 return okOptional('set-simulator-location is installed');155 }156 return nokOptional('set-simulator-location is not installed');157 }158 async fix () { // eslint-disable-line require-await159 return `${'set-simulator-location'.bold} is needed to set location for Simulator. ` +160 'Please read https://github.com/lyft/set-simulator-location to install it';161 }162}163checks.push(new OptionalLyftCommandCheck());164class OptionalIdbCommandCheck extends DoctorCheck {165 async diagnose () {166 const fbIdbPath = await resolveExecutablePath('idb');167 const fbCompanionIdbPath = await resolveExecutablePath('idb_companion');168 if (fbIdbPath && fbCompanionIdbPath) {169 return okOptional('idb and idb_companion are installed');170 }171 if (!fbIdbPath && fbCompanionIdbPath) {172 return nokOptional('idb is not installed');173 } else if (fbIdbPath && !fbCompanionIdbPath) {174 return nokOptional('idb_companion is not installed');175 }176 return nokOptional('idb and idb_companion are not installed');177 }178 async fix () { // eslint-disable-line require-await179 return `Why ${'idb'.bold} is needed and how to install it: https://github.com/appium/appium-idb`;180 }181}182checks.push(new OptionalIdbCommandCheck());183class OptionalApplesimutilsCommandCheck extends DoctorCheck {184 async diagnose () {185 const applesimutilsPath = await resolveExecutablePath('applesimutils');186 return applesimutilsPath187 ? okOptional(`applesimutils is installed at: ${applesimutilsPath}. Installed versions are: ${(await exec('brew', ['list', '--versions', 'applesimutils'])).stdout.trim()}`)188 : nokOptional('applesimutils cannot be found');189 }190 async fix () { // eslint-disable-line require-await191 return `Why ${'applesimutils'.bold} is needed and how to install it: http://appium.io/docs/en/drivers/ios-xcuitest/`;192 }193}194checks.push(new OptionalApplesimutilsCommandCheck());195class OptionalIOSDeployCommandCheck extends DoctorCheck {196 async diagnose () {197 const iosDeployPath = await resolveExecutablePath('ios-deploy');198 return iosDeployPath199 ? okOptional(`ios-deploy is installed at: ${iosDeployPath}. Installed version is: ${(await exec(iosDeployPath, ['-V'])).stdout.trim()}`)200 : nokOptional('ios-deploy cannot be found');201 }202 async fix () { // eslint-disable-line require-await203 return `${'ios-deploy'.bold} is used as a fallback command to install iOS applications to real device. Please read https://github.com/ios-control/ios-deploy/ to install it`;204 }205}206checks.push(new OptionalIOSDeployCommandCheck());207export {208 fixes, XcodeCheck, XcodeCmdLineToolsCheck, DevToolsSecurityCheck,209 AuthorizationDbCheck, CarthageCheck, OptionalIdbCommandCheck, OptionalApplesimutilsCommandCheck,210 OptionalIOSDeployCommandCheck, OptionalLyftCommandCheck211};...

Full Screen

Full Screen

android-specs.js

Source:android-specs.js Github

copy

Full Screen

1// transpile:mocha2import { EnvVarAndPathCheck, AndroidToolCheck, OptionalAppBundleCheck, OptionalGstreamerCheck } from '../lib/android';3import { fs } from 'appium-support';4import * as adb from 'appium-adb';5import * as utils from '../lib/utils';6import * as tp from 'teen_process';7import chai from 'chai';8import { withMocks, stubEnv } from 'appium-test-support';9import B from 'bluebird';10import {removeColors} from './helper';11chai.should();12describe('android', function () {13 describe('EnvVarAndPathCheck', withMocks({fs}, (mocks) => {14 stubEnv();15 let check = new EnvVarAndPathCheck('ANDROID_HOME');16 it('autofix', function () {17 check.autofix.should.not.be.ok;18 });19 it('diagnose - success', async function () {20 process.env.ANDROID_HOME = '/a/b/c/d';21 mocks.fs.expects('exists').once().returns(B.resolve(true));22 (await check.diagnose()).should.deep.equal({23 ok: true,24 optional: false,25 message: 'ANDROID_HOME is set to: /a/b/c/d'26 });27 mocks.verify();28 });29 it('failure - not set', async function () {30 delete process.env.ANDROID_HOME;31 const {ok, optional, message} = await check.diagnose();32 ok.should.be.false;33 optional.should.be.false;34 message.should.not.be.empty;35 mocks.verify();36 });37 it('failure - file not exists', async function () {38 process.env.ANDROID_HOME = '/a/b/c/d';39 mocks.fs.expects('exists').once().returns(B.resolve(false));40 (await check.diagnose()).should.deep.equal({41 ok: false,42 optional: false,43 message: 'ANDROID_HOME is set to \'/a/b/c/d\' ' +44 'but this is NOT a valid path!'45 });46 mocks.verify();47 });48 it('fix', async function () {49 removeColors(await check.fix()).should.contain('ANDROID_HOME');50 });51 }));52 describe('AndroidToolCheck', withMocks({adb}, (mocks) => {53 stubEnv();54 const check = new AndroidToolCheck();55 it('autofix', function () {56 check.autofix.should.not.be.ok;57 });58 it('diagnose - success', async function () {59 process.env.ANDROID_HOME = '/a/b/c/d';60 mocks.adb.expects('getAndroidBinaryPath').exactly(4).returns(B.resolve('/path/to/binary'));61 (await check.diagnose()).should.deep.equal({62 ok: true,63 optional: false,64 message: 'adb, android, emulator, apkanalyzer exist: /a/b/c/d'65 });66 mocks.verify();67 });68 it('diagnose - failure - no ANDROID_HOME', async function () {69 delete process.env.ANDROID_HOME;70 delete process.env.ANDROID_SDK_ROOT;71 (await check.diagnose()).should.deep.equal({72 ok: false,73 optional: false,74 message: 'adb, android, emulator, apkanalyzer could not be found because ANDROID_HOME or ANDROID_SDK_ROOT is NOT set!'75 });76 mocks.verify();77 });78 it('diagnose - failure - path not valid', async function () {79 process.env.ANDROID_HOME = '/a/b/c/d';80 mocks.adb.expects('getAndroidBinaryPath').exactly(4).throws();81 (await check.diagnose()).should.deep.equal({82 ok: false,83 optional: false,84 message: 'adb, android, emulator, apkanalyzer could NOT be found in /a/b/c/d!'85 });86 mocks.verify();87 });88 it('fix - ANDROID_HOME', async function () {89 delete process.env.ANDROID_HOME;90 removeColors(await check.fix()).should.equal('Manually configure ANDROID_HOME ' +91 'and run appium-doctor again.');92 });93 it('fix - install', async function () {94 process.env.ANDROID_HOME = '/a/b/c/d';95 removeColors(await check.fix()).should.equal('Manually install adb, android, emulator, apkanalyzer and add it to PATH. ' +96 'https://developer.android.com/studio#cmdline-tools and ' +97 'https://developer.android.com/studio/intro/update#sdk-manager may help to setup.');98 });99 }));100 describe('OptionalAppBundleCheck', withMocks({tp, utils}, (mocks) => {101 let check = new OptionalAppBundleCheck();102 it('autofix', function () {103 check.autofix.should.not.be.ok;104 });105 it('diagnose - success', async function () {106 mocks.utils.expects('resolveExecutablePath').once().returns('path/to/bundletool.jar');107 (await check.diagnose()).should.deep.equal({108 ok: true,109 optional: true,110 message: 'bundletool.jar is installed at: path/to/bundletool.jar'111 });112 mocks.verify();113 });114 it('diagnose - failure', async function () {115 mocks.utils.expects('resolveExecutablePath').once().returns(false);116 (await check.diagnose()).should.deep.equal({117 ok: false,118 optional: true,119 message: 'bundletool.jar cannot be found'120 });121 mocks.verify();122 });123 it('fix', async function () {124 removeColors(await check.fix()).should.equal('bundletool.jar is used to handle Android App Bundle. Please read http://appium.io/docs/en/writing-running-appium/android/android-appbundle/ to install it');125 });126 }));127 describe('OptionalGstreamerCheck', withMocks({tp, utils}, (mocks) => {128 let check = new OptionalGstreamerCheck();129 it('autofix', function () {130 check.autofix.should.not.be.ok;131 });132 it('diagnose - success', async function () {133 mocks.utils.expects('resolveExecutablePath').once().returns('path/to/gst-launch');134 mocks.utils.expects('resolveExecutablePath').once().returns('path/to/gst-inspect');135 (await check.diagnose()).should.deep.equal({136 ok: true,137 optional: true,138 message: 'gst-launch-1.0 and gst-inspect-1.0 are installed at: path/to/gst-launch and path/to/gst-inspect'139 });140 mocks.verify();141 });142 it('diagnose - failure', async function () {143 mocks.utils.expects('resolveExecutablePath').twice().returns(false);144 (await check.diagnose()).should.deep.equal({145 ok: false,146 optional: true,147 message: 'gst-launch-1.0 and/or gst-inspect-1.0 cannot be found'148 });149 mocks.verify();150 });151 it('fix', async function () {152 removeColors(await check.fix()).should.equal('gst-launch-1.0 and gst-inspect-1.0 are used to stream the screen of the device under test. ' +153 'Please read https://appium.io/docs/en/writing-running-appium/android/android-screen-streaming/ to install them and for more details');154 });155 }));...

Full Screen

Full Screen

android.js

Source:android.js Github

copy

Full Screen

...64checks.push(new AndroidToolCheck());65checks.push(new JavaOnPathCheck());66class OptionalAppBundleCheck extends DoctorCheck {67 async diagnose () {68 const bundletoolPath = await resolveExecutablePath('bundletool.jar');69 return bundletoolPath70 ? okOptional(`bundletool.jar is installed at: ${bundletoolPath}`)71 : nokOptional('bundletool.jar cannot be found');72 }73 async fix () { // eslint-disable-line require-await74 return `${'bundletool.jar'.bold} is used to handle Android App Bundle. Please read http://appium.io/docs/en/writing-running-appium/android/android-appbundle/ to install it` +75 `${system.isWindows() ? '. Also consider adding the ".jar" extension into your PATHEXT environment variable in order to fix the problem for Windows' : ''}`;76 }77}78checks.push(new OptionalAppBundleCheck());79class OptionalGstreamerCheck extends DoctorCheck {80 GSTREAMER_BINARY = `gst-launch-1.0${system.isWindows() ? '.exe' : ''}`;81 GST_INSPECT_BINARY = `gst-inspect-1.0${system.isWindows() ? '.exe' : ''}`;82 async diagnose () {83 const gstreamerPath = await resolveExecutablePath(this.GSTREAMER_BINARY);84 const gstInspectPath = await resolveExecutablePath(this.GST_INSPECT_BINARY);85 return gstreamerPath && gstInspectPath86 ? okOptional(`${this.GSTREAMER_BINARY} and ${this.GST_INSPECT_BINARY} are installed at: ${gstreamerPath} and ${gstInspectPath}`)87 : nokOptional(`${this.GSTREAMER_BINARY} and/or ${this.GST_INSPECT_BINARY} cannot be found`);88 }89 async fix () { // eslint-disable-line require-await90 return `${`${this.GSTREAMER_BINARY} and ${this.GST_INSPECT_BINARY}`.bold} are used to stream the screen of the device under test. ` +91 'Please read https://appium.io/docs/en/writing-running-appium/android/android-screen-streaming/ to install them and for more details';92 }93}94checks.push(new OptionalGstreamerCheck());95export { EnvVarAndPathCheck, AndroidToolCheck, JavaOnPathCheck, OptionalAppBundleCheck, OptionalGstreamerCheck };...

Full Screen

Full Screen

utils.js

Source:utils.js Github

copy

Full Screen

...75 * @param {string} packageName A package name to get path and version data76 * @return {?NpmPackageInfo}77 */78async function getNpmPackageInfo (packageName) {79 const npmPath = await resolveExecutablePath(`npm${system.isWindows() ? `.cmd` : ''}`);80 if (!npmPath) {81 return nokOptional(`'npm' binary not found in PATH: ${process.env.PATH}`);82 }83 let pJson = {};84 try {85 const {stdout} = await exec(npmPath, ['list', '-g', '-l', '-j', packageName]);86 pJson = JSON.parse(stdout);87 } catch (err) {88 log.debug(err);89 return null;90 }91 if (pJson.dependencies && pJson.dependencies[packageName]) {92 return {version: pJson.dependencies[packageName].version, path: pJson.path};93 }...

Full Screen

Full Screen

dev.js

Source:dev.js Github

copy

Full Screen

...10 super();11 this.binary = binary;12 }13 async diagnose () {14 const resolvedPath = await resolveExecutablePath(this.binary);15 if (!resolvedPath) {16 return nok(`${this.binary} is MISSING in PATH: ${process.env.PATH}`);17 }18 return ok(`${this.binary} was found at ${resolvedPath}`);19 }20 fix () {21 return `Manually install the ${this.binary.bold} binary and add it to ${'PATH'.bold}.`;22 }23}24checks.push(new BinaryIsInPathCheck(system.isWindows() ? 'mvn.bat' : 'mvn'));25checks.push(new BinaryIsInPathCheck(system.isWindows() ? 'ant.bat' : 'ant'));26checks.push(new BinaryIsInPathCheck(system.isWindows() ? 'adb.exe' : 'adb'));27// Check Android SDKs28class AndroidSdkExists extends DoctorCheck {...

Full Screen

Full Screen

carthage-detector.js

Source:carthage-detector.js Github

copy

Full Screen

1import log from './logger';2import { resolveExecutablePath } from './utils';3class CarthageDetector {4 static async detect () {5 const carthagePath = await resolveExecutablePath('carthage');6 if (!carthagePath) {7 log.debug(`Carthage was not found in PATH: ${process.env.PATH}`);8 return null;9 }10 log.debug(`Carthage was found at: ${carthagePath}`);11 return carthagePath;12 }13}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({4 executablePath: await puppeteer.executablePath(),5 });6 const page = await browser.newPage();7 await page.screenshot({path: 'google.png'});8 await browser.close();9})();10const puppeteer = require('puppeteer');11(async () => {12 const browser = await puppeteer.launch({13 });14 const page = await browser.newPage();15 await page.screenshot({path: 'google.png'});16 await browser.close();17})();18const puppeteer = require('puppeteer');19(async () => {20 const browser = await puppeteer.launch({21 });22 const page = await browser.newPage();23 await page.screenshot({path: 'google.png'});24 await browser.close();25})();26const puppeteer = require('puppeteer');27(async () => {28 const browser = await puppeteer.launch({29 });30 const page = await browser.newPage();31 await page.screenshot({path: 'google.png'});32 await browser.close();33})();34const puppeteer = require('puppeteer');35(async () => {36 const browser = await puppeteer.launch({37 });38 const page = await browser.newPage();39 await page.screenshot({path: 'google.png'});40 await browser.close();41})();42const puppeteer = require('puppeteer');43(async () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({4 executablePath: await puppeteer.executablePath(),5 });6 const page = await browser.newPage();7 await page.screenshot({path: 'example.png'});8 await browser.close();9})();10const puppeteer = require('puppeteer');11(async () => {12 const browser = await puppeteer.launch({13 executablePath: await puppeteer.executablePath(),14 });15 const page = await browser.newPage();16 await page.screenshot({path: 'example.png'});17 await browser.close();18})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3const browser = await puppeteer.launch({4executablePath: await puppeteer.executablePath(),5});6const page = await browser.newPage();7})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({4 executablePath: await puppeteer.executablePath(),5 });6 const page = await browser.newPage();7})();8(async () => {9 const browser = await puppeteer.launch({10 });11 const page = await browser.newPage();12})();13(async () => {14 const browser = await puppeteer.launch({15 });16 const page = await browser.newPage();17})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const executablePath = puppeteer.executablePath();3console.log(executablePath);4const puppeteer = require('puppeteer');5const executablePath = puppeteer.executablePath();6console.log(executablePath);7const puppeteer = require('puppeteer');8const executablePath = puppeteer.executablePath();9console.log(executablePath);10const puppeteer = require('puppeteer');11const executablePath = puppeteer.executablePath();12console.log(executablePath);13const puppeteer = require('puppeteer');14const executablePath = puppeteer.executablePath();15console.log(executablePath);16const puppeteer = require('puppeteer');17const executablePath = puppeteer.executablePath();18console.log(executablePath);19const puppeteer = require('puppeteer');20const executablePath = puppeteer.executablePath();21console.log(executablePath);22const puppeteer = require('puppeteer');23const executablePath = puppeteer.executablePath();24console.log(executablePath);25const puppeteer = require('puppeteer');26const executablePath = puppeteer.executablePath();27console.log(executablePath);28const puppeteer = require('puppeteer');29const executablePath = puppeteer.executablePath();30console.log(executablePath);31const puppeteer = require('puppeteer');32const executablePath = puppeteer.executablePath();33console.log(executablePath);34const puppeteer = require('puppeteer');

Full Screen

Using AI Code Generation

copy

Full Screen

1(async () => {2const browser = await puppeteer.launch({3executablePath: puppeteer.executablePath(),4});5const page = await browser.newPage();6await page.screenshot({ path: 'google.png' });7await browser.close();8})();9(async () => {10const browser = await puppeteer.launch({11executablePath: puppeteer.executablePath(),12});13const page = await browser.newPage();14await page.screenshot({ path: 'google.png' });15await browser.close();16})();17(async () => {18const browser = await puppeteer.launch({19executablePath: puppeteer.executablePath(),20});21const page = await browser.newPage();22await page.screenshot({ path: 'google.png' });23await browser.close();24})();25(async () => {26const browser = await puppeteer.launch({27executablePath: puppeteer.executablePath(),28});29const page = await browser.newPage();30await page.screenshot({ path: 'google.png' });31await browser.close();32})();33(async () => {34const browser = await puppeteer.launch({35executablePath: puppeteer.executablePath(),36});37const page = await browser.newPage();38await page.screenshot({ path: 'google.png' });39await browser.close();40})();41(async () => {42const browser = await puppeteer.launch({43executablePath: puppeteer.executablePath(),44});45const page = await browser.newPage();46await page.screenshot({ path: 'google.png' });47await browser.close();48})();49(async () => {50const browser = await puppeteer.launch({

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 console.log(await browser.version());5 await browser.close();6})();7const puppeteer = require('puppeteer');8(async () => {9 const browser = await puppeteer.launch();10 console.log(await browser.version());11 await browser.close();12})();13const puppeteer = require('puppeteer');14(async () => {15 const browser = await puppeteer.launch({16 });17 console.log(await browser.version());18 await browser.close();19})();20const puppeteer = require('puppeteer');21(async () => {22 const browser = await puppeteer.launch({headless: false});23 const page = await browser.newPage();24 await browser.close();25})();26const puppeteer = require('puppeteer');27(async () => {28 const browser = await puppeteer.launch({headless: false});29 const page = await browser.newPage();30 await browser.close();31})();32const puppeteer = require('puppeteer');33(async () => {34 const browser = await puppeteer.launch({headless: false});

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const path = require('path');3(async () => {4 const browser = await puppeteer.launch({5 executablePath: await puppeteer.executablePath(),6 defaultViewport: {7 }8 });9 const page = await browser.newPage();10 await page.screenshot({path: 'google.png'});11 await browser.close();12})();13Operating System Browser Executable Path Windows C:\Program Files (x86)\Google\Chrome\Application\chrome.exe MacOS /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome Linux /usr/bin/google-chrome

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const browserFetcher = puppeteer.createBrowserFetcher();3browserFetcher.download('609904').then(() => {4 console.log('Download complete');5 const executablePath = browserFetcher.revisionInfo('609904').executablePath;6 console.log('Executable path is ' + executablePath);7});8const puppeteer = require('puppeteer');9const browserFetcher = puppeteer.createBrowserFetcher();10browserFetcher.download('609904').then(() => {11 console.log('Download complete');12 const executablePath = browserFetcher.revisionInfo('609904').executablePath;13 console.log('Executable path is ' + executablePath);14});15const puppeteer = require('puppeteer');16const browserFetcher = puppeteer.createBrowserFetcher();17browserFetcher.download('609904').then(() => {18 console.log('Download complete');19 const executablePath = browserFetcher.revisionInfo('609904').executablePath;20 console.log('Executable path is ' + executablePath);21});22const puppeteer = require('puppeteer');23const browserFetcher = puppeteer.createBrowserFetcher();24browserFetcher.download('609904').then(() => {25 console.log('Download complete');26 const executablePath = browserFetcher.revisionInfo('609904').executablePath;27 console.log('Executable path is ' + executablePath);28});29const puppeteer = require('p

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Puppeteer automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful