Best JavaScript code snippet using puppeteer
docare.test.js
Source:docare.test.js
...47 await login.click()48 await page.type(".login_container input[data-key='email']", email)49 await page.type(".login_container input[data-key='password']", "1234")50 await page.click("button.save_login")51 await page.waitForNetworkIdle()52 }53 const register = async (page, email) => {54 const register = await getByText(page, "a", "Register")55 await register.click()56 await page.type(".register_container input[data-key='email']", email)57 await page.type(".register_container input[data-key='password']", "1234")58 await page.type(".register_container input[data-key='name']", "Sadko")59 await page.click("button.save_register")60 await page.waitForNetworkIdle()61 }62 it("should Register", async () => {63 await goToDocare(page)64 await register(page, "wand")65 await getByText(page, "a", "Log Out")66 })67 it("should Login", async () => {68 await goToDocare(page)69 await login(page, "wand")70 await getByText(page, "a", "Log Out")71 const page2 = await context.newPage()72 await goToDocare(page2)73 await getByText(page2, "a", "Log Out")74 await page2.close()75 const logout = await getByText(page, "a", "Log Out")76 await logout.click()77 await getByText(page, "a", "Register")78 })79 const addPatient = async (page, name, phone) => {80 await page.click("button.add_btn")81 await page.type(".add_patient input[data-key='name']", name)82 await page.type(".add_patient input[data-key='age']", "45")83 await page.type(".add_patient input[data-key='gender']", "female")84 await page.type(".add_patient input[data-key='disease']", "zob")85 await page.type(".add_patient input[data-key='treatment']", "qolodaniye")86 await page.type(".add_patient input[data-key='address']", "Khatai")87 await page.type(".add_patient input[data-key='phone']", phone)88 await page.click(".add_patient .save")89 await page.waitForNetworkIdle()90 }91 const checkPatient = async (page, name) => {92 const el = await getByText(page, "label", name)93 await el.click()94 }95 const getElementText = (page, selector) => {96 return page.$eval(selector, (element) => {97 return element.textContent98 })99 }100 const getNumPatients = (page) => {101 return page.$eval(".content>.list>table>tbody", (element) => {102 return element.childElementCount - 1103 })104 }105 it("should add patient", async () => {106 await goToDocare(page)107 await register(page, "nuna")108 await addPatient(page, "Sasha", "456")109 await addPatient(page, "Saida", "123")110 // await page.waitForTimeout(300000)111 const numChildren = await getNumPatients(page)112 const nameSaida = await getElementText(113 page,114 ".content>.list>table>tbody>tr:nth-child(2)>td.name>label"115 )116 const phoneSaida = await getElementText(117 page,118 ".content>.list>table>tbody>tr:nth-child(2)>td.phone"119 )120 const nameSasha = await getElementText(121 page,122 ".content>.list>table>tbody>tr:nth-child(3)>td.name>label"123 )124 const phoneSasha = await getElementText(125 page,126 ".content>.list>table>tbody>tr:nth-child(3)>td.phone"127 )128 expect(numChildren).toBe(2)129 expect(phoneSaida).toBe("123")130 expect(nameSaida).toBe("Saida")131 expect(phoneSasha).toBe("456")132 expect(nameSasha).toBe("Sasha")133 })134 it("should delete patient", async () => {135 await goToDocare(page)136 await register(page, "sadko")137 await addPatient(page, "Aygun", "789")138 await addPatient(page, "Sabina", "7913")139 await addPatient(page, "Eva", "012")140 await checkPatient(page, "Aygun")141 await checkPatient(page, "Sabina")142 await expect(getByText(page, "label", "Aygun")).resolves.toBeTruthy()143 await page.click(".del_btn")144 await page.waitForNetworkIdle()145 const numChildren = await getNumPatients(page)146 expect(numChildren).toBe(1)147 await expect(getByText(page, "label", "Aygun")).rejects.toThrow()148 })149 it("should filter patient", async () => {150 await goToDocare(page)151 await register(page, "filtermail")152 await addPatient(page, "Aygun", "789")153 await addPatient(page, "Sabina", "7913")154 await addPatient(page, "Eva", "012")155 await page.type(".container .search input", "Sabina")156 await page.keyboard.press("Enter")157 await page.waitForNetworkIdle()158 // await page.waitForTimeout(300000)159 await expect(getByText(page, "label", "Aygun")).rejects.toThrow()160 await expect(getByText(page, "label", "Eva")).rejects.toThrow()161 await expect(getByText(page, "label", "Sabina")).resolves.toBeTruthy()162 })163 it("should sort by name", async () => {164 await goToDocare(page)165 await register(page, "sortmail")166 await addPatient(page, "Aygun", "789")167 await addPatient(page, "Sabina", "7913")168 await addPatient(page, "Eva", "012")169 await page.select(".container .sort select", "name")170 await page.waitForNetworkIdle()171 // await page.waitForTimeout(300000)172 const nameAygun = await getElementText(173 page,174 ".content>.list>table>tbody>tr:nth-child(2)>td.name>label"175 )176 const nameEva = await getElementText(177 page,178 ".content>.list>table>tbody>tr:nth-child(3)>td.name>label"179 )180 const nameSabina = await getElementText(181 page,182 ".content>.list>table>tbody>tr:nth-child(4)>td.name>label"183 )184 expect(nameAygun).toBe("Aygun")185 expect(nameSabina).toBe("Sabina")186 expect(nameEva).toBe("Eva")187 })188 const addPatientForSort = async (page, name, age, treatment) => {189 await page.click("button.add_btn")190 await page.type(".add_patient input[data-key='name']", name)191 await page.type(".add_patient input[data-key='age']", age)192 await page.type(".add_patient input[data-key='gender']", "female")193 await page.type(".add_patient input[data-key='disease']", "zob")194 await page.type(".add_patient input[data-key='treatment']", treatment)195 await page.type(".add_patient input[data-key='address']", "Khatai")196 await page.type(".add_patient input[data-key='phone']", "123")197 await page.click(".add_patient .save")198 await page.waitForNetworkIdle()199 }200 it("should sort by age", async () => {201 await goToDocare(page)202 await register(page, "sortage")203 await addPatientForSort(page, "Aygun", "21", "voda")204 await addPatientForSort(page, "Sabina", "32", "xleb")205 await addPatientForSort(page, "Eva", "26", "saxalin")206 await page.select(".container .sort select", "age")207 await page.waitForNetworkIdle()208 // await page.waitForTimeout(300000)209 const nameAygun = await getElementText(210 page,211 ".content>.list>table>tbody>tr:nth-child(2)>td.name>label"212 )213 const nameEva = await getElementText(214 page,215 ".content>.list>table>tbody>tr:nth-child(3)>td.name>label"216 )217 const nameSabina = await getElementText(218 page,219 ".content>.list>table>tbody>tr:nth-child(4)>td.name>label"220 )221 expect(nameAygun).toBe("Aygun")222 expect(nameSabina).toBe("Sabina")223 expect(nameEva).toBe("Eva")224 })225 it("should sort by treatment", async () => {226 await goToDocare(page)227 await register(page, "sorttreatment")228 await addPatientForSort(page, "Aygun", "21", "80")229 await addPatientForSort(page, "Sabina", "32", "75")230 await addPatientForSort(page, "Eva", "26", "12")231 await page.select(".container .sort select", "treatment")232 await page.waitForNetworkIdle()233 // await page.waitForTimeout(300000)234 const nameAygun = await getElementText(235 page,236 ".content>.list>table>tbody>tr:nth-child(4)>td.name>label"237 )238 const nameEva = await getElementText(239 page,240 ".content>.list>table>tbody>tr:nth-child(2)>td.name>label"241 )242 const nameSabina = await getElementText(243 page,244 ".content>.list>table>tbody>tr:nth-child(3)>td.name>label"245 )246 expect(nameAygun).toBe("Aygun")247 expect(nameSabina).toBe("Sabina")248 expect(nameEva).toBe("Eva")249 })250 it("should paging", async () => {251 await goToDocare(page)252 await register(page, "paging")253 await addPatient(page, "ghygun", "743589")254 await addPatient(page, "Sabina", "7913")255 await addPatient(page, "feEva", "012")256 await addPatient(page, "rerygun", "43")257 await addPatient(page, "dSabina", "34")258 await addPatient(page, "Eva", "234")259 await addPatient(page, "adygun", "8")260 await addPatient(page, "Sabina", "565")261 await addPatient(page, "uyEva", "012")262 await addPatient(page, "Aygun", "789")263 await addPatient(page, "koSabina", "9")264 await addPatient(page, "Eva", "4012")265 const numChildren = await getNumPatients(page)266 expect(numChildren).toBe(10)267 await page.click(".page_info>button.right")268 await page.waitForNetworkIdle()269 const numChildrenP2 = await getNumPatients(page)270 // await page.waitForTimeout(300000)271 expect(numChildrenP2).toBe(2)272 })...
index.js
Source:index.js
...50 await this.page.focus("#tPassword");51 await this.page.type("#tPassword", password);52 await this.page.waitForSelector("#bLogin");53 await this.page.click("#bLogin");54 await this.page.waitForNetworkIdle();55 if (this.page.url().toLowerCase().includes("login")) {56 throw INVALID_CREDENTIALS;57 }58 }59 /**60 * Ensure that the browser has been initialised and that the user is logged in61 */62 async _ensureInitialisedAndAuthenticated() {63 await this._ensureInitialised();64 await this.page.goto(this.baseUrl);65 if (this.page.url().includes("Login")) {66 throw LOGIN_REQUIRED;67 }68 return true;69 }70 /**71 * Retreive available course timetable options including list of courses and levels.72 * @param {Object} opts An object containing any of `levelId` or `courseSearchString` to filter courses.73 * @returns {Promise<Object>} An object containing a list of courses, levels74 * and other available options values to pass to getCourseTimetable()75 *76 * @example77 *78 * // Get Course & Level Options79 * const courseOptions = await scraper.getCourseOptions()80 * console.log(courseOptions.courses)81 * console.log(courseOptions.levels)82 *83 * // Get options with course search filter84 * const filteredCourseOptions = await scraper.getCourseOptions({85 * courseSearchString: 'Computer Science'86 * })87 *88 * // Get options with level filter89 * const foundationCourseOptions = await scraper.getCourseOptions({90 * levelId: '0'91 * })92 */93 async getCourseOptions(opts = { levelId: null, courseSearchString: null }) {94 if (!opts) opts = {};95 if (!opts.levelId) opts.levelId = null;96 if (!opts.courseSearchString) opts.courseSearchString = null;97 await this._ensureInitialisedAndAuthenticated();98 // Navigate to the course options page99 await this.page.waitForSelector("#LinkBtn_pos");100 await this.page.click("#LinkBtn_pos");101 // Filter to level if specified102 if (opts.levelId) {103 await this.page.waitForSelector("#dlFilter");104 await this.page.select("#dlFilter", opts.levelId);105 await this.page.waitForNetworkIdle();106 }107 // Filter to search string if specified108 if (opts.courseSearchString) {109 await this.page.waitForSelector("#tWildcard");110 await this.page.type("#tWildcard", opts.courseSearchString);111 await this.page.click("#bWildcard");112 }113 await this.page.waitForNetworkIdle();114 await this.page.waitForSelector("#dlObject");115 await this.page.waitForSelector("#dlFilter");116 await this.page.waitForSelector("#lbWeeks");117 await this.page.waitForSelector("#lbDays");118 return await this.page.evaluate(() => {119 return {120 levels: Array.from(document.getElementById("dlFilter").children)121 .map((level) => {122 return {123 name: level.textContent,124 id: level.getAttribute("value"),125 };126 })127 .filter((level) => level.id !== ""),128 courses: Array.from(document.querySelector("#dlObject")).map(129 (courseOption) => {130 return {131 id: courseOption.value,132 name: courseOption.textContent,133 };134 }135 ),136 periods: Array.from(document.getElementById("lbWeeks").children)137 .map((period) => {138 return {139 id: period.value,140 name: period.textContent,141 };142 })143 .filter((period) => period.id !== ""),144 days: Array.from(document.getElementById("lbDays").children)145 .map((day) => {146 return {147 id: day.value,148 name: day.textContent,149 };150 })151 .filter((day) => day.id !== ""),152 };153 });154 }155 /**156 * Retreive a timetable for one or more courses.157 * @param {Object} opts Object containing a list of courseIds, periodIds and158 * dayIds identifying the timetable to retrieve. These IDs can be found by calling `getCourseOptions()`.159 */160 async getCourseTimetable(161 opts = { courseIds: [], periodId: "1-51", daysId: "1-7" }162 ) {163 if (!opts) opts = {};164 if (!opts.courseIds) opts.courseIds = [];165 if (!opts.periodId) opts.periodId = "1-51";166 if (!opts.daysId) opts.daysId = "1-7";167 if (opts.courseIds.length === 0) {168 throw NO_COURSES_SELECTED;169 }170 if (opts.courseIds.length > 8) {171 throw TOO_MANY_COURSES;172 }173 await this._ensureInitialisedAndAuthenticated();174 // Navigate to Course Timetable Page175 await this.page.waitForNetworkIdle();176 await this.page.waitForSelector("#LinkBtn_pos");177 await this.page.click("#LinkBtn_pos");178 // Select Courses179 await this.page.waitForNetworkIdle();180 await this.page.waitForSelector("#dlObject");181 await this.page.select("#dlObject", ...opts.courseIds);182 // Select Period183 await this.page.waitForNetworkIdle();184 await this.page.waitForSelector("#lbWeeks");185 await this.page.select("#lbWeeks", opts.periodId);186 // Select Days187 await this.page.waitForNetworkIdle();188 await this.page.waitForSelector("#lbDays");189 await this.page.select("#lbDays", opts.daysId);190 // Select List Timetable Report Type191 await this.page.waitForNetworkIdle();192 await this.page.waitForSelector("#dlType");193 await this.page.select(194 "#dlType",195 "TextSpreadsheet;swsurl;SWSCUST Object TSS-Footer"196 );197 // Click Submit198 await this.page.waitForNetworkIdle();199 await this.page.waitForSelector("#bGetTimetable");200 await this.page.click("#bGetTimetable");201 // Wait for timetable to load202 await this.page.waitForNetworkIdle();203 // Parse Timetable204 return await this.page.evaluate(() => {205 const tables = document.querySelectorAll("table.spreadsheet");206 const days = [];207 for (const table of tables) {208 const rows = table.querySelectorAll("tr");209 const day = [];210 for (const row of rows) {211 if (row.classList.contains("columnTitles")) {212 continue;213 }214 day.push(215 Array.from(row.querySelectorAll("td")).map((cell) => {216 return cell.textContent;...
scrapeListingsHelpers.test.js
Source:scrapeListingsHelpers.test.js
...37 });38 test("should return true if listing has error", async () => {39 const listingUrl = "https://www.airbnb.co.uk/rooms/33571268";40 await page.goto(listingUrl);41 await page.waitForNetworkIdle();42 expect(await checkForError(page, listingUrl)).toBe(true);43 });44 test("should return false if listing does not have error", async () => {45 const listingUrl = "https://www.airbnb.co.uk/rooms/20669368";46 await page.goto(listingUrl);47 await page.waitForNetworkIdle();48 expect(await checkForError(page, listingUrl)).toBe(false);49 });50 test("should return property name from valid listing", async () => {51 const listingUrl = "https://www.airbnb.co.uk/rooms/20669368";52 await page.goto(listingUrl);53 await page.waitForNetworkIdle();54 expect(await getPropertyName(page)).toBe(55 "Little Country Houses - Poppy's Pad"56 );57 });58 test("should return property type from valid listing", async () => {59 const listingUrl = "https://www.airbnb.co.uk/rooms/20669368";60 await page.goto(listingUrl);61 await page.waitForNetworkIdle();62 expect(await getPropertyType(page)).toBe("Tiny house");63 });64 test("should return details list from valid listing", async () => {65 const listingUrl = "https://www.airbnb.co.uk/rooms/20669368";66 await page.goto(listingUrl);67 await page.waitForNetworkIdle();68 const expected = ["4 guests", "1 bedroom", "1 bed", "1 bathroom"];69 expect(await getDetailsList(page)).toEqual(expected);70 });71 test("should return amenities list from valid listing", async () => {72 const listingUrl = "https://www.airbnb.co.uk/rooms/20669368";73 await page.goto(listingUrl);74 await page.waitForNetworkIdle();75 const amenitiesModalLink = await getAmenitiesModalLink(page);76 await page.goto(amenitiesModalLink);77 await page.waitForNetworkIdle();78 const expected = [79 "Suitable for events",80 "Indoor fireplace",81 "Heating",82 "Smoke alarm",83 "Fire extinguisher",84 "First aid kit",85 "Kitchen",86 "Refrigerator",87 "Cooking basics",88 "Oven",89 "Patio or balcony",90 "BBQ grill",91 "Free parking on premises",...
crawling-web.js
Source:crawling-web.js
...36 try {37 const page = await browser.newPage();38 await page._client.send('Page.setDownloadBehavior', { behavior: 'allow', downloadPath: `./${persist ? endDate.split('/').join('-') : ''}` })39 await page.goto(LINK);40 await page.waitForNetworkIdle();41 await waitElementAndClick(page, 'div[data-tb-test-id="tabStoryPoint-4"]');42 await delay();43 await page.waitForNetworkIdle();44 await delay();45 await changeFilterDate(page, startDate, endDate);46 await delay();47 await page.waitForNetworkIdle();48 await delay();49 await waitElementAndClick(page, '#download-ToolbarButton')50 await delay();51 await waitElementAndClick(page, 'button[data-tb-test-id="DownloadCrosstab-Button"]')52 await delay();53 await waitElementAndClick(page, 'div[data-tb-test-id="sheet-thumbnail-1"]')54 await delay();55 await waitElementAndClick(page, 'button[data-tb-test-id="export-crosstab-export-Button"]')56 await delay();57 await page.waitForNetworkIdle();58 await extractData(endDate, data, persist);59 } catch (error) {60 console.log(error);61 } finally {62 await browser.close();63 }64 console.timeEnd('start');...
create-test-files.js
Source:create-test-files.js
...24 cy.viewport(1000, 1000)25 cy.reload(true)26 cy.task('log', 'baseline-1')27 cy.waitForStableDOM()28 // cy.waitForNetworkIdle(\`**\${url}**\`, 1000)29 cy.task('log', 'baseline-2')30 cy.screenshot(constructFile({ url, type: 'baseline' }), { capture: 'viewport' })31 cy.task('log', 'artifact')32 // Create artifact33 cy.viewport(1000, 1000)34 cy.reload(true)35 cy.task('log', 'artifact-1')36 cy.waitForStableDOM()37 // cy.waitForNetworkIdle(\`**\${url}**\`, 1000)38 cy.task('log', 'artifact-2')39 cy.screenshot(constructFile({ url, type: 'artifact' }), { capture: 'viewport' })40 // cy.task('log', 'regression')41 // // Create regression42 // cy.viewport(1000, 1000)43 // cy.reload(true)44 // cy.task('log', 'regression-1')45 // cy.waitForStableDOM()46 // // cy.waitForNetworkIdle(\`**\${url}**\`, 1000)47 // cy.task('log', 'regression-2')48 // cy.createRegression()49 // cy.task('log', 'regression-3')50 // cy.screenshot(constructFile({ url, type: 'regression' }), { capture: 'viewport' })51 // cy.task('log', 'regression-4')52 })53})54`;55for (let i = 0; i < NUM_TEST_FILES; i++) {56 const file = path.resolve(__dirname, `cypress/integration/generate-data-${i}.spec.js`)57 fs.writeFileSync(file, createTestFile(i));...
jwalker-sf.js
Source:jwalker-sf.js
...7 logger.debug("Salesforce initial auth page loaded.");8 /* Click on the SSO button */9 await Promise.all([10 page.click('#idp_section_buttons > button > span'),11 waitForNetworkIdle(page, 2000, 0),12 logger.debug("Navigating to SSO page."),13 ]);14 /* Enter username/password */15 logger.debug("Will now enter username/password...");16 await Promise.all([17 logger.silly("In await Promise.all..."),18 await page.type('#username', username),19 await page.type('#password', password),20 await page.keyboard.press('Enter'),21 logger.info("Logged in to Salesforce. Please wait " + timeout / 1000 + " seconds..."),22 await sleep(timeout),23 logger.debug("calling waitForNetworkIdle"),24 waitForNetworkIdle(page, 1000, 0),25 logger.debug("Salesforce case page loaded."),26 ]);27 return page;28};29async function sleep(ms) {30 return new Promise((resolve) => {31 setTimeout(resolve, ms);32 });33}34/* Use if 500ms timeout of 'networkidleX' is insufficient */35var waitForNetworkIdle = exports.waitForNetworkIdle = function (page, timeout, maxInflightRequests = 0) {36 page.on('request', onRequestStarted);37 page.on('requestfinished', onRequestFinished);38 page.on('requestfailed', onRequestFinished);...
app.js
Source:app.js
...19 const pages = await ins.browser.pages()20 const page = pages[0]21 22 await page.goto('https://wallet.wax.io')23 await page.waitForNetworkIdle()24 await page.waitForTimeout(200)25 await page.waitForSelector('input[name="userName"]')26 await page.type('input[name="userName"]', email)27 await page.type('input[name="password"]', password)28 await page.click('.button-primary')29 await page.waitForNetworkIdle()30 await page.waitForSelector('.button.primary')31 const otp = authenticator.generate(secrect.replaceAll(' ', ''))32 await page.type('input', otp)33 await page.click('.button.primary')34 await page.waitForNetworkIdle()35 await page.waitForFunction('window.wax?.api')36 37 ins.wallet = await page.evaluate(() => wax.userAccount)38 39 page.on('popup', async (popup) => {40 await popup.waitForNetworkIdle()41 await popup.waitForSelector('.button-secondary')42 popup.click('.button-secondary')43 })44 45 ins.transact = async (...args) => {46 const result = await page.evaluate(async (...args) => {47 return wax.api.transact(...args)48 }, ...args)49 }50 51 return ins52 } catch (e) {53 error = e54 ins.browser?.close()...
index.spec.js
Source:index.spec.js
...20 // Create baseline21 cy.viewport(1000, 1000)22 cy.reload(true)23 cy.task('log', 'baseline-1')24 cy.waitForNetworkIdle(`**${url}**`, 1000)25 cy.task('log', 'baseline-2')26 cy.screenshot(constructFile({ url, type: 'baseline' }), { capture: 'viewport' })27 28 cy.task('log', 'artifact')29 // Create artifact30 cy.viewport(1000, 1000)31 cy.reload(true)32 cy.task('log', 'artifact-1')33 cy.waitForNetworkIdle(`**${url}**`, 1000)34 cy.task('log', 'artifact-2')35 cy.screenshot(constructFile({ url, type: 'artifact' }), { capture: 'viewport' })36 37 cy.task('log', 'regression')38 // Create regression39 cy.viewport(1000, 1000)40 cy.reload(true)41 cy.task('log', 'regression-1')42 cy.waitForNetworkIdle(`**${url}**`, 1000)43 cy.task('log', 'regression-2')44 cy.createRegression()45 cy.task('log', 'regression-3')46 cy.screenshot(constructFile({ url, type: 'regression' }), { capture: 'viewport' })47 cy.task('log', 'regression-4')48 })49 })...
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 await page.waitForNavigation({waitUntil: 'networkidle0'});6 await browser.close();7})();8const puppeteer = require('puppeteer');9(async () => {10 const browser = await puppeteer.launch();11 const page = await browser.newPage();12 await page.waitForNavigation({waitUntil: 'networkidle0'});13 await browser.close();14})();15const puppeteer = require('puppeteer');16(async () => {17 const browser = await puppeteer.launch();18 const page = await browser.newPage();19 await page.waitForNavigation({waitUntil: 'networkidle0'});20 await browser.close();21})();22const puppeteer = require('puppeteer');23(async () => {24 const browser = await puppeteer.launch();25 const page = await browser.newPage();26 await page.waitForNavigation({waitUntil: 'networkidle0'});27 await browser.close();28})();29const puppeteer = require('puppeteer');30(async () => {31 const browser = await puppeteer.launch();32 const page = await browser.newPage();33 await page.waitForNavigation({waitUntil: 'networkidle0'});34 await browser.close();35})();36const puppeteer = require('puppeteer');37(async () => {38 const browser = await puppeteer.launch();39 const page = await browser.newPage();40 await page.waitForNavigation({waitUntil: 'networkidle0'});41 await browser.close();42})();43const puppeteer = require('puppeteer');
Using AI Code Generation
1const puppeteer = require('puppeteer');2const fs = require('fs');3(async () => {4 const browser = await puppeteer.launch({5 });6 const page = await browser.newPage();7 await page.waitForNetworkIdle(5000);8 await page.screenshot({path: 'google.png'});9 await browser.close();10})();11{12 "scripts": {13 },14 "dependencies": {15 }16}17const puppeteer = require('puppeteer');18const fs = require('fs');19(async () => {20 const browser = await puppeteer.launch({21 });22 const page = await browser.newPage();23 await page.waitForNetworkIdle(5000);24 await page.screenshot({path: 'google.png'});25 await browser.close();26})();27{28 "scripts": {29 },30 "dependencies": {31 }32}33const puppeteer = require('puppeteer');34const fs = require('fs');35(async () => {36 const browser = await puppeteer.launch({37 });38 const page = await browser.newPage();
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!