添加链接
注册
登录
link管理
链接快照平台
输入网页链接,自动生成快照
标签化管理网页链接
相关文章推荐
另类的砖头
·
7款强大的Javascript网格插件推荐 ...
·
4 周前
·
追风的水煮鱼
·
wolfcrypt: the ...
·
1 月前
·
爱喝酒的皮带
·
javascript ...
·
1 月前
·
傻傻的作业本
·
iota币论坛_扬光币圈-虚拟币行情与资讯发布平台
·
6 月前
·
慈祥的萝卜
·
vue3 ...
·
9 月前
·
link管理
›
Use createCDPSession in Puppeteer With Examples | LambdaTest
https://www.lambdatest.com/automation-testing-advisor/javascript/puppeteer-createCDPSession
重感情的金鱼
5 月前
</noscript><section class="relative z-10 desktop:hidden" style="background:#0A1429"><div class="container__selenium"><div class="banner_cookie py-10 px-14"><div class="text-white xlm:text-size-14 text-size-13 font-medium text-center tracking-wider smtablet:leading-7 flex items-center justify-center"><span class="inline-block w-140 h-1 mr-10" style="background:linear-gradient(270deg, #FFFFFF 0%, rgba(255, 255, 255, 0) 98.26%)"/><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/TestmuHeaderLogo.svg" class="w-20 mx-5" alt="LambdaTest G2 Announcement" width="24" height="27"/><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/noto_rocket.svg" class="w-20 mx-5" alt="LambdaTest G2 Announcement" width="20" height="20"/>TestMu Conference is Back! Future of Testing + AI<a href="https://www.lambdatest.com/testmuconf-2024/" class="font-bold rounded-md py-6 px-10 mx-5 hover:underline" style="background:linear-gradient(132.55deg, #FFA03C 5.93%, #B02DFF 99.91%)">Register for Free</a><span class="inline-block w-140 h-1 ml-10" style="background:linear-gradient(270deg, #FFFFFF 0%, rgba(255, 255, 255, 0) 98.26%);transform:rotate(180deg)"/></div></div></div></section><header id="header" class="undefined"><nav class="container"><div class="px-2 desktop:py-15"><div class="flex -mx-2 items-center desktop:block"><div class="header__logo px-2 desktop:w-full"><div class="flex items-center desktop:justify-between"><div class="tools_logo"><a href="https://www.lambdatest.com/"><img src="https://www.lambdatest.com/automation-testing-advisor/resources/images/logos/logo.svg" alt="Logo" width="147" height="26"/></a></div><button class="hidden desktop:block"><img loading="eager" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/icons/toggle_menu.svg" class="w-22 h-22" alt="..." width="150" height="150"/></button></div></div><div class="header__menu px-2 desktop:w-full"><div class="desktop:mt-10 desktop:text-left desktop:hidden"><div class="flex items-center desktop:block "><div class="w-7/12 desktop:w-full header__menu__items"><div class="inline-block dropdown desktop:block resource-dropdown"><div><a href="https://www.lambdatest.com/feature" class="desktop:block text-ltBlack-400 desktop:ml-0 desktop:mt-10 nav-link pt-10 pb-10 text-size-16 font-medium px-15 fromipad:px-10 block sm:inline-block dropdown-toggle menu-item focus:outline-none desktop:pointer-events-none">Platform <i class="header arrow_down"/></a></div><div class="text-left dropdown-menu resource-dropdown-menu bg-white p-0 absolute top-auto left-0 rounded hasPointer desktop:static desktop:z-50"><div class="table__main"><div class="grid grid-flow-col grid-cols-3 w-full desktop:block"><div class="col-span-2 desktop:col-auto desktop:mb-20"><div class="grid grid-flow-col grid-cols-2 w-full pt-40 product__dropdown desktop:block desktop:pt-0"><div class="col-span-1 dropdowm-section"><ul class="header_inner header-icon"><li class=""><a href="https://www.lambdatest.com/online-browser-testing" class="flex "><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Browser-testing.svg" alt="Browser Testing" width="25" height="24"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Online Browser Testing</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Manual live-interactive cross browser testing</p></div></a></li><li class=""><a href="https://www.lambdatest.com/selenium-automation" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/selenium.svg" alt="Selenium" width="26" height="26"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Selenium Testing</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Run Selenium scripts on cloud-based infrastructure</p></div></a></li><li class=""><a href="https://www.lambdatest.com/cypress-testing" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/header_cypress.svg" alt="Lambdatest Cypress" width="24" height="24"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Cypress Testing</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Run Cypress scripts on cloud-based infrastructure</p></div></a></li><li class=""><a href="https://www.lambdatest.com/playwright-testing" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/playwright.svg" alt="Playwright" width="25" height="19"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Playwright Testing</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Run Playwright scripts on cloud-based infrastructure</p></div></a></li><li class=""><a href="https://www.lambdatest.com/hyperexecute" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Hypertest.svg" alt="HyperExecute" width="26" height="26"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">HyperExecute</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Blazing fast AI-powered automation testing cloud</p></div></a></li><li class="flex "><a href="https://www.lambdatest.com/on-premise-selenium-grid" class="flex "><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/selenium.svg" alt="On-Premise Selenium Grid" width="26" height="26"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">On-Premise Selenium Grid</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Our cloud infrastructure paired with security of your firewall</p></div></a></li></ul></div><div class="col-span-1 dropdowm-section"><ul class="header_inner header-icon"><li class="flex"><a href="https://www.lambdatest.com/accessibility-testing" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/AccessibilityTesting_blue.svg" class="accBlue_int hidden w-25 h-auto" alt="Accessibility Testing" width="34" height="38"/><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/AccessibilityTesting_Black.svg" class="beta_int accBlack_int w-25 h-auto" alt="Accessibility Testing" width="34" height="38"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Accessibility Testing</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Test the accessibility of websites and web apps</p></div></a></li><li class=""><a href="https://www.lambdatest.com/real-device-cloud" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Real-devices.svg" alt="Real Devices Cloud" width="24" height="24"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Real Devices Cloud</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Test web and mobile applications on real devices</p></div></a></li><li class=""><a href="https://www.lambdatest.com/visual-regression-testing" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Visual-Regression.svg" alt="Visual Regression" width="24" height="24"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Visual Regression Cloud</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">AI-powered automated visual UI testing on cloud</p></div></a></li><li class=""><a href="https://www.lambdatest.com/test-intelligence/" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Logo_TI.svg" alt="Test Intelligence" width="30" height="30"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal flex items-center">Test Intelligence <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/IntelligenceBeta.svg" class="ml-5 beta_int" alt="..." width="29" height="15"/></h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">AI-powered test intelligence insights</p></div></a></li><li class=""><a href="https://www.lambdatest.com/automation-cloud" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Automation-testing-cloud.svg" alt="Automation Testing Cloud" width="24" height="20"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Automation Testing Cloud</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Run automation test on a scalable cloud-based</p></div></a></li><li class=""><a href="https://www.lambdatest.com/test-on-smart-tv" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/smart-TV.svg" alt=" Smart TV Testing Cloud" width="24" height="24"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Smart TV Testing Cloud</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Automate app testing on Smart TV with LambdaTest cloud.</p></div></a></li></ul></div></div></div><div class="col-span-1 bg-lambda-300 dropdowm-section pl-50 pb-10 pt-50 smtablet:pl-10 smtablet:pt-20"><div class="flex items-baseline product_tool relative"><p class=" text-size-18 font-semibold tracking-wide text-ltBlack-100 uppercase mt-0 mb-28 ">Tools</p><a href="https://www.lambdatest.com/downloads" class="text-lambda-900 text-size-16 font-medium leading-normal tracking-wide flex items-center header_btn">All Tools<img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/slider/arrow.svg" class="ml-10 w-16 h-16" alt="Arrow" width="16" height="16"/></a></div><ul class="header_inner w-10/12 header-icon smtablet:w-full"><li class=""><a href="https://www.lambdatest.com/accessibility-devtools" class="flex items-baseline"><div class="w-25"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/AccessibilityDevtools_blue.svg" class="accBlue_int hidden w-25 h-auto" alt="Accessibility Devtools" width="34" height="38"/><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/AccessibilityDevtools_black.png" class="beta_int accBlack_int w-25 h-auto" alt="Accessibility Devtools" width="34" height="38"/></div><div class="ml-26 product_tool_content smtablet:ml-10"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal flex items-center">Accessibility DevTools <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/New.svg" class="ml-5 beta_int" alt="..." width="29" height="15"/></h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Easily test, manage, and report accessibility issues</p></div></a></li><li class=""><a href="https://www.lambdatest.com/lt-browser/" class="flex items-baseline"><div class="w-25"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/ltbrowser-logo.svg" alt="LambdaTest LT Browser" width="22" height="22"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">LT Browser</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Next-gen browser to build, test & debug responsive websites</p></div></a></li><li class=""><a href="https://www.lambdatest.com/test-analytics" class="flex items-baseline"><div class="w-25"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/analytics.svg" class="w-full h-auto" alt="Test Analytics" width="22" height="20"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Test Analytics</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">LambdaTest's AI-Powered Test Analytics & Observability Suite</p></div></a></li></ul><div class="flex items-baseline product_integration relative mt-30"><p class=" text-size-18 font-semibold tracking-wide text-ltBlack-100 uppercase mt-0 mb-28 ">Integrations</p><a href="https://www.lambdatest.com/integrations" class="text-lambda-900 text-size-16 font-medium leading-normal tracking-wide flex items-center header_btn">See all 120+<img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/slider/arrow.svg" class="ml-10 w-16 h-16" alt="Arrow" width="16" height="16"/></a></div><ul class="flex items-center hover-integration"><li class="mr-30"><a href="https://www.lambdatest.com/support/docs/jenkins-with-lambdatest/"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/jenkin.png" alt="Jenkin" width="27" height="38" title="Jenkin"/></a></li><li class="mr-30"><a href="https://www.lambdatest.com/support/docs/github-integration/"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/GithubIcon.svg" class="opacity-50" alt="Github" width="32" height="31" title="Github"/></a></li><li class="mr-30"><a href="https://www.lambdatest.com/support/docs/slack-integration/"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/slack.svg" alt="Slack" width="33" height="32" title="Slack"/></a></li><li class="mr-30"><a href="https://www.lambdatest.com/support/docs/katalon-integration-with-lambdatest/"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Katalon.svg" alt="Katalon" width="29" height="29" title="Katalon"/></a></li><li class="mr-30"><a href="https://www.lambdatest.com/support/docs/jasmine-with-karma-running-jasmine-tests-on-lambdatest-selenium-grid/"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/header-Jasmine.png" alt="Jasmine" width="33" height="33" title="Jasmine"/></a></li><li class="mr-30"><a href="https://www.lambdatest.com/support/docs/trello-integration/"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Trello_Logo.svg" class="w-90" alt="Trello" width="661" height="223" title="Trello"/></a></li></ul></div></div></div><div class="border-t-2 border-b-2 border-red-1000 bg-red-1000 py-25 header__bottom"><div class="table__main pl-20 desktop:pl-0"><ul class="flex items-center product_logo smtablet:w-full smtablet:block desktop:pl-10"><li class="mr-36 text-size-16 font-normal tracking-wide leading-normal text-ltBlack-50 automation__tool smtablet:block smtablet:mb-10">Automation tools</li><li class="mr-15 xl:mr-30 selenium_automation"><a href="https://www.lambdatest.com/selenium-automation"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Selenium_product.svg" class="w-30" alt="selenium" width="357" height="374" title="Selenium"/></a></li><li class="mr-15 xl:mr-30"><a href="https://www.lambdatest.com/appium-mobile-testing"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Appium-logo.png" alt="Appium" width="98" height="25" title="Appium"/></a></li><li class=" mr-15 xl:mr-36"><a href="https://www.lambdatest.com/playwright-testing"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Playwright_logo.svg" class="w-150" alt="Playwright" width="774" height="156" title="Playwright"/></a></li><li class="mr-15 xl:mr-36"><a href="https://www.lambdatest.com/cypress-testing"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Cypress.png" alt="Cypress" width="74" height="25" title="Cypress"/></a></li><li class=" mr-15 xl:mr-36"><a href="https://www.lambdatest.com/puppeteer-testing"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/puppteer-icon.png" class="w-130 h-auto" alt="Puppeteer" width="226" height="84" title="Puppeteer"/></a></li><li class=" mr-15 xl:mr-36"><a href="https://www.lambdatest.com/webdriverio-testing"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/webdriverio.svg" class="w-70" alt="WebdriverIO" width="40" height="27" title="WebdriverIO"/></a></li><li class="mr-15 xl:mr-30"><a href="https://www.lambdatest.com/testcafe-testing"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/testcafe.png" alt="testcafe" width="100" height="19" title="TestCafe"/></a></li><li class="mr-15 xl:mr-5"><a href="https://www.lambdatest.com/xcuitest-app-testing"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/XCUITest.svg" class="w-130" alt="XCUnit" width="347" height="100" title="XCUnit"/></a></li><li class=" mr-15 xl:mr-10"><a href="https://www.lambdatest.com/espresso-automation-testing"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/espresso-testing.png" class="w-150" alt="Espresso" width="347" height="100" title="Espresso"/></a></li><li class=""><a href="https://www.lambdatest.com/k6-browser-testing"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/k6.svg" class="xl:w-50 w-30" alt="Espresso" width="105" height="101" title="Espresso"/></a></li></ul></div></div></div></div><div class="inline-block dropdown desktop:block resource-dropdown"><button class="desktop:block text-ltBlack-400 desktop:ml-0 desktop:mt-10 nav-link pt-10 pb-10 text-size-16 font-medium px-15 fromipad:px-10 block sm:inline-block dropdown-toggle menu-item focus:outline-none">Enterprise <i class="header arrow_down"/></button><div class="text-left dropdown-menu resource-dropdown-menu bg-white p-0 absolute top-auto left-0 rounded hasPointer desktop:static desktop:z-50 resource_ep"><div class="table__main"><div class="table w-full desktop:block"><div class="table-cell pb-50 pt-20 desktop:block desktop:w-full"><div class="table w-full desktop:block"><div class="table-cell dropdowm-section desktop:w-full desktop:block"><ul class="header_inner header-icon"><li><a href="https://www.lambdatest.com/enterprise" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/digital_icon.svg" alt="Digital Experince Testing" width="26" height="26"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Digital Experience Testing</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Unified testing cloud to help deliver immersive digital experience</p></div></a></li><li><a href="https://www.lambdatest.com/enterprise-execution-environment" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/enterprise_icon.svg" alt="Enterprise Execution Environment" width="26" height="26"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Enterprise Execution Environment</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Single execution environment to meet all enterprise testing needs</p></div></a></li></ul></div></div></div></div></div></div></div><div class="inline-block dropdown desktop:block resource-dropdown"><button class="desktop:block text-ltBlack-400 desktop:ml-0 desktop:mt-10 nav-link pt-10 pb-10 text-size-16 font-medium px-15 fromipad:px-10 block sm:inline-block dropdown-toggle menu-item focus:outline-none">Resources <i class="header arrow_down"/></button><div class="text-left dropdown-menu resource-dropdown-menu bg-white p-0 absolute top-auto left-0 rounded hasPointer desktop:static desktop:z-50"><div class="table__main"><div class="table w-full desktop:block"><div class="table-cell w-8/12 pb-20 desktop:w-full desktop:block"><div class="table w-full desktop:block"><div class="table-cell w-1/2 dropdowm-section desktop:w-full desktop:block"><h2 class="relative text-size-18 font-semibold tracking-wide text-ltBlack-100 uppercase mt-50 mb-20 pl-20 desktop:mt-20">Learn</h2><ul class="header_inner header-icon"><li class=""><a href="https://www.lambdatest.com/blog/" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/header-blog.svg" alt="Lambdatest Blog" width="24" height="24"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Blog</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Blogs on Selenium automation testing, CI/CD, and more</p></div></a></li><li class=""><a href="https://www.lambdatest.com/webinar/" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/header-webinar.svg" alt="Lambdatest Webinar" width="24" height="24"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Webinars</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Live virtual workshops around test automation</p></div></a></li><li class=""><a href="https://www.lambdatest.com/learning-hub/" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/hub.svg" alt="Lambdatest LearningHub" width="24" height="24"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Learning Hub</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">End-to-end guides on Selenium, cross browser testing, CI/CD, and more</p></div></a></li><li class=""><a href="https://www.lambdatest.com/video/" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/header-video-logo.svg" alt="Lambdatest Videos" width="24" height="24"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Videos</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Video tutorials around automation testing and LambdaTest</p></div></a></li><li class=""><a href="https://www.lambdatest.com/customers/" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/study.svg" alt="Lambdatest Case Studies" width="24" height="24"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Customer Stories</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Read the success stories of industry leaders</p></div></a></li><li class=""><a href="/community" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/header-community.svg" alt="Lambdatest Community" width="22" height="22"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">LambdaTest for Community</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Learn about our programs and get support</p></div></a></li></ul></div><div class="table-cell w-1/2 dropdowm-section desktop:w-full desktop:block"><h2 class="relative text-size-18 font-semibold tracking-wide text-ltBlack-100 uppercase mt-50 mb-20 pl-20 desktop:mt-30">Engage</h2><ul class="header_inner header-icon"><li class=""><a href="https://www.lambdatest.com/support/docs/" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/LambdaTest-Documentation.svg" alt="Lambdatest Documentation" width="24" height="24"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Documentation</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Step-by-step guides to get started with LambdaTest</p></div></a></li><li class=""><a href="https://www.lambdatest.com/support/api-doc/" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/api.svg" alt="Lambdatest API" width="24" height="24"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">API</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Extract, delete & modify data in bulk using LambdaTest API<!-- --> </p></div></a></li><li class=""><a href="https://www.lambdatest.com/newsletter/" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/header-newsletter-logo.svg" alt="Lambdatest Newsletter" width="26" height="26"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Newsletter</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Testing insights and tips delivered weekly</p></div></a></li><li class=""><a href="https://community.lambdatest.com/" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/header-community.svg" alt="Lambdatest Community" width="22" height="22"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Community & Support</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Connect, ask & learn with tech-savvy folks</p></div></a></li><li class=""><a href="https://www.lambdatest.com/certifications/" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/header-certificate.svg" alt="Lambdatest Certifications" width="22" height="22"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Certifications</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Advance your career with LambdaTest Certifications</p></div></a></li><li class=""><a href="https://www.lambdatest.com/lambdatest-write-for-us" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/WriteusIcon.svg" alt="Lambdatest Certifications" width="22" height="22"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Write for Us</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Join the guest blogger program to share insights</p></div></a></li></ul></div></div></div><div class="table-cell w-4/12 bg-lambda-300 dropdowm-section pl-50 pb-50 desktop:w-full smtablet:pl-15 smtablet:pr-15"><h2 class="relative text-size-18 font-semibold tracking-wide text-ltBlack-100 uppercase mt-50 mb-28 desktop:mt-30">What’s New</h2><div class="w-8/12 smtablet:w-full"><a href="https://www.lambdatest.com/testmuconf-2024"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header_testmu2024.png" alt="Testμ Conference" width="800" height="600"/></a><a href="https://www.lambdatest.com/testmuconf-2024" class="text-size-16 font-medium text-ltBlack-50 leading-snug inline-block mt-21 mb-14 hover:underline resource_anchor">Join 30,000+ testers/devs at TestMu Conference | Grab free pass</a><p class="text-size-14 font-normal leading-normal text-gray-850 mb-8">Attend 35+ sessions, workshops, and panel discussions featuring 60+ speakers. Hottest topics in Quality Engineering and Testing!</p><a href="https://www.lambdatest.com/testmuconf-2024" class="text-lambda-900 text-size-16 font-medium leading-normal tracking-wide flex items-center header_btn">Register Now<img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/slider/arrow.svg" class="ml-10 w-16 h-16" alt="Arrow" width="16" height="16"/></a></div></div></div></div></div></div><div class="inline-block dropdown desktop:block resource-dropdown"><button class="desktop:block text-ltBlack-400 desktop:ml-0 desktop:mt-10 nav-link pt-10 pb-10 text-size-16 font-medium px-15 fromipad:px-10 block sm:inline-block dropdown-toggle menu-item focus:outline-none">Developers <i class="header arrow_down"/></button><div class="text-left dropdown-menu resource-dropdown-menu bg-white p-0 absolute top-auto left-0 rounded hasPointer desktop:static desktop:z-50"><div class="table__main"><div class="table w-full desktop:block"><div class="table-cell w-8/12 pb-20 desktop:block desktop:w-full"><div class="table w-full desktop:block"><div class="table-cell w-1/2 dropdowm-section desktop:w-full desktop:block"><h2 class="relative text-size-18 font-semibold tracking-wide text-ltBlack-100 uppercase mt-50 mb-28 pl-20 desktop:mt-20">Get Started</h2><ul class="header_inner header-icon"><li><a href="https://www.lambdatest.com/support/docs/getting-started-with-lambdatest-automation/" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/selenium.svg" alt="Lambdatest Selenium" width="26" height="26"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Selenium</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Run first Selenium test on LambdaTest Grid</p></div></a></li><li><a href="https://www.lambdatest.com/support/docs/getting-started-with-cypress-testing/" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/header_cypress.svg" alt="Lambdatest Cypress" width="24" height="24"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Cypress</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Run first Cypress test on LambdaTest Grid</p></div></a></li><li><a href="https://www.lambdatest.com/support/docs/mobile-web-automation-on-real-devices/" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Mobile-App-Testing.svg" alt="Lambdatest Mobile App Testing" width="24" height="24"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Mobile App Testing</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Test native apps on 50+ devices</p></div></a></li><li><a href="https://www.lambdatest.com/support/docs/real-time-browser-testing/" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/RealTime-web-testing.svg" alt="Lambdatest Real Time Web Testing" width="26" height="26"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Real Time Web Testing</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Test websites or web apps on 3000+ browsers</p></div></a></li></ul></div><div class="table-cell w-1/2 dropdowm-section desktop:w-full desktop:block"><h2 class="relative text-size-18 font-semibold tracking-wide text-ltBlack-100 uppercase mt-50 mb-28 pl-20 desktop:mt-20">Guides</h2><ul class="header_inner header-icon"><li><a href="https://changelog.lambdatest.com/" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Lambda-Changelog.svg" alt="Changelog" width="24" height="24"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Changelog</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">All LambdaTest announcements</p></div></a></li><li><a href="https://www.lambdatest.com/support/docs/" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/LambdaTest-Documentation.svg" alt="Lambdatest Documentation" width="24" height="24"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">Documentation</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Step-by-step guides to get started with LambdaTest</p></div></a></li><li><a href="https://www.lambdatest.com/support/api-doc/" class="flex"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/api.svg" alt="Lambdatest API" width="24" height="24"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal">API</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Extract, delete & modify data in bulk using LambdaTest API<!-- --> </p></div></a></li><li><a href="https://github.com/LambdaTest" rel="noopener noreferrer" target="_blank" class="flex "><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/header_github.svg" alt="Lambdatest GitHub Repositories" width="24" height="24"/></div><div class="ml-26"><h3 class="text-size-18 font-medium text-ltBlack-50 tracking-normal flex items-center relative gitrepo_img">GitHub Repositories</h3><p class="text-gray-850 text-size-15 leading-normal tracking-normal">Check GitHub repos for ready-to-run code<!-- --> </p></div></a></li></ul></div></div></div><div class="table-cell w-4/12 bg-lambda-300 dropdowm-section pl-50 pb-30 smtablet:pl-15 smtablet:pr-15"><h2 class="relative text-size-18 font-semibold tracking-wide text-ltBlack-100 uppercase mt-50 mb-15 developer_dropdown desktop:mt-30">Languages & frameworks</h2><div id="frameworks_section" class="frameworks_line pt-10 pb-15"><div id="frameworks_logo_main" class="hover-framework"><div class="flex items-center"><a href="https://www.lambdatest.com/support/docs/selenide-tests-with-lambdatest-online-selenium-grid-for-automated-cross-browser-testing/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/selenide-logo.png" alt="selenide" width="55" height="29" title="Selenide"/></a><a href="https://www.lambdatest.com/support/docs/running-gauge-tests-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Gauge-Logo.svg" class="opacity-50" alt="Gauge" width="62" height="18" title="Gauge"/></a><a href="https://www.lambdatest.com/support/docs/testng-with-selenium-running-java-automation-scripts-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/testng.png" alt="testng" width="42" height="22" title="TestNG"/></a><a href="https://www.lambdatest.com/support/docs/run-geb-tests-on-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/g23.png" alt="geb" width="43" height="14" title="Geb"/></a><a href="https://www.lambdatest.com/support/docs/junit-with-selenium-running-junit-automation-scripts-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/junit.png" alt="junit" width="33" height="33" title="JUnit"/></a></div></div><div id="frameworks_heading" class="text-size-14 font-medium text-ltBlack-300 tracking-wide leading-normal">Java</div></div><div id="frameworks_section" class="frameworks_line pt-10 pb-15"><div id="frameworks_logo_main" class="hover-framework"><div class="flex items-center"><a href="https://www.lambdatest.com/support/docs/webdriverio-5-6-2-with-selenium-running-automation-scripts-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/WebDriverIO.png" alt="WebDriverIO" width="25" height="27" title="WebDriverIO"/></a><a href="https://www.lambdatest.com/support/docs/nightwatch-with-selenium-running-nightwatch-automation-scripts-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Nightwatchjs_Logo.svg" class="w-28" alt="NightwatchJS" width="472" height="605" title="NightwatchJS"/></a><a href="https://www.lambdatest.com/support/docs/automation-testing-with-mocha-and-selenium/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Mocha.png" alt="Mocha" width="33" height="33" title="Mocha"/></a><a href="https://www.lambdatest.com/support/docs/jasmine-with-karma-running-jasmine-tests-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Jasmine.png" alt="Jasmine" width="27" height="27" title="Jasmine"/></a><a href="https://www.lambdatest.com/support/docs/npm-plugin-for-testcafe-integration-with-lambdatest/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/testcafe.png" alt="testcafe" width="70" height="14" title="TestCafe"/></a></div></div><div id="frameworks_heading" class="text-size-14 font-medium text-ltBlack-300 tracking-wide leading-normal">Node.js</div></div><div id="frameworks_section" class="frameworks_line pt-10 pb-15"><div id="frameworks_logo_main" class="hover-framework"><div class="flex items-center"><a href="https://www.lambdatest.com/support/docs/specflow-with-selenium-running-specflow-automation-scripts-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/SpecFlow.png" alt="SpecFlow" width="75" height="25" title="SpecFlow"/></a><a href="https://www.lambdatest.com/support/docs/mstest-with-selenium-running-mstest-automation-scripts-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/MSTest.png" alt="MSTest" width="37" height="32" title="MSTest"/></a><a href="https://www.lambdatest.com/support/docs/nunit-with-selenium-running-nunit-automation-scripts-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/NUnit.png" alt="NUnit" width="47" height="25" title="NUnit"/></a></div></div><div id="frameworks_heading" class="text-size-14 font-medium text-ltBlack-300 tracking-wide leading-normal">C#</div></div><div id="frameworks_section" class="frameworks_line pt-10 pb-15"><div id="frameworks_logo_main" class="hover-framework"><div class="flex items-center"><a href="https://www.lambdatest.com/support/docs/laravel-dusk-with-selenium-running-laravel-dusk-automation-scripts-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Laravel_Logo.svg" class="w-30" alt="laravel" width="646" height="672" title="Laravel"/></a><a href="https://www.lambdatest.com/support/docs/codeception-integration-with-lambdatest/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Codeception_Logo.svg" class="w-30" alt="Codeception" width="605" height="449" title="Codeception"/></a><a href="https://www.lambdatest.com/support/docs/phpunit-with-selenium-running-phpunit-automation-scripts-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/phpunit_framework.svg" class="w-50" alt="PHPUnit" width="713" height="182" title="PHPUnit"/></a><a href="https://www.lambdatest.com/support/docs/behat-with-selenium-running-behat-automation-scripts-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Behat.png" class="opacity-50" alt="Behat" width="49" height="15" title="Behat"/></a></div></div><div id="frameworks_heading" class="text-size-14 font-medium text-ltBlack-300 tracking-wide leading-normal">PHP</div></div><div id="frameworks_section" class="frameworks_line pt-10 pb-15"><div id="frameworks_logo_main" class="hover-framework"><div class="flex items-center"><a href="https://www.lambdatest.com/support/docs/pytest-with-selenium-running-pytest-automation-script-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/pytest.png" alt="pytest" width="25" height="25" title="Pytest"/></a><a href="https://www.lambdatest.com/support/docs/behave-with-selenium-running-behave-automation-scripts-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Behave.png" alt="Behave" width="31" height="29" title="Behave"/></a><a href="https://www.lambdatest.com/support/docs/robot-with-selenium-running-robot-automation-scripts-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Robot.png" alt="Robot" width="25" height="24" title="Robot"/></a><a href="https://www.lambdatest.com/support/docs/running-unit-testing-in-python-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/unitTest.png" alt="unitTest" width="21" height="31" title="Unittest"/></a></div></div><div id="frameworks_heading" class="text-size-14 font-medium text-ltBlack-300 tracking-wide leading-normal">Python</div></div><div id="frameworks_section" class="frameworks_line pt-10 pb-15"><div id="frameworks_logo_main" class="hover-framework"><div class="flex items-center"><a href="https://www.lambdatest.com/support/docs/rspec-with-selenium-running-rspec-automation-scripts-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/RSpec.png" alt="RSpec" width="29" height="29" title="RSpec"/></a><a href="https://www.lambdatest.com/support/docs/cucumberjs-with-selenium-running-cucumberjs-automation-scripts-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Cucumber.png" alt="Cucumber" width="93" height="30" title="Cucumber"/></a><a href="https://www.lambdatest.com/support/docs/testunit-with-selenium-running-testunit-automation-scripts-on-lambdatest-selenium-grid/" class="mr-20"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/TestUnit.png" alt="TestUnit" width="33" height="33" title="Test::Unit"/></a></div></div><div id="frameworks_heading" class="text-size-14 font-medium text-ltBlack-300 tracking-wide leading-normal">Ruby</div></div><div class="frameworks_all"><a href="https://www.lambdatest.com/support/docs/getting-started-with-lambdatest-automation/" class="text-lambda-900 text-size-16 font-medium leading-normal tracking-wide flex items-center mt-20 header_btn">See all<img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/slider/arrow.svg" class="ml-10 w-16 h-16" alt="Arrow" width="16" height="16"/></a></div></div></div></div><div class="border-t-2 border-b-2 border-lambda-60 bg-lambda-60 py-25 header__bottom"><div class="table__main pl-20 smtablet:pl-0"><ul class="flex items-center developer_logo"><li class="mr-36 smtablet:mr-10"><a href="https://www.lambdatest.com/support/faq/" class="flex items-center"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Logo_FAQ.svg" alt="Lambdatest FAQs" width="24" height="24"/></div><div class="ml-15 smtablet:ml-4"><h3 class="text-size-18 font-semibold text-ltBlack-200 tracking-normal smtablet:text-size-11">FAQs</h3></div></a></li><li class="mr-36 smtablet:mr-10"><a href="https://www.lambdatest.com/selenium" class="flex items-center"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/selenium_black_logo.svg" alt="Selenium" width="24" height="24"/></div><div class="ml-15 smtablet:ml-4"><h3 class="text-size-18 font-semibold text-ltBlack-200 tracking-normal smtablet:text-size-11">Selenium Guide</h3></div></a></li><li class="mr-36 smtablet:mr-10"><a href="https://www.lambdatest.com/learning-hub/cypress-tutorial" class="flex items-center"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/header_cypress.svg" alt="Lambdatest Cypress" width="24" height="24" style="filter:brightness(0)"/></div><div class="ml-15 smtablet:ml-4"><h3 class="text-size-18 font-semibold text-ltBlack-200 tracking-normal smtablet:text-size-11">Cypress Guide</h3></div></a></li><li class=" mr-36 smtablet:mr-10 smtablet:hidden"><a href="https://www.lambdatest.com/web-technologies" class="flex items-center"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/browsers.svg" alt="Lambdatest Cross Browser Testing" width="24" height="24"/></div><div class="ml-15 smtablet:ml-4"><h3 class="text-size-18 font-semibold text-ltBlack-200 tracking-normal smtablet:text-size-11">Web Technologies Compatibility</h3></div></a></li><li class=" mr-36 smtablet:mr-10 smtablet:hidden"><a href="https://www.lambdatest.com/automation-testing-advisor" class="flex items-center"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/automation-advisor.svg" alt="Lambdatest Cross Browser Testing" width="25" height="25"/></div><div class="ml-15 smtablet:ml-4"><h3 class="text-size-18 font-semibold text-ltBlack-200 tracking-normal smtablet:text-size-11">Automation Testing Advisor</h3></div></a></li><li class=" mr-36 smtablet:mr-10 smtablet:hidden"><a href="https://www.lambdatest.com/mobile-testing-advisor/" class="flex items-center"><div><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/header/Mobile-advisor.svg" alt="Lambdatest Cross Browser Testing" width="25" height="25"/></div><div class="ml-15 smtablet:ml-4"><h3 class="text-size-18 font-semibold text-ltBlack-200 tracking-normal smtablet:text-size-11">Mobile Testing Advisor</h3></div></a></li></ul></div></div></div></div><a href="https://www.lambdatest.com/pricing" class="desktop:block desktop:ml-0 desktop:mt-10 nav-link inline-block pt-10 pb-10 text-size-16 font-medium px-15 fromipad:px-10 text-ltBlack-400 ">Pricing</a></div><div class="w-5/12 md:text-right desktop:text-left desktop:w-full desktop:px-15 relative flex desktop:block items-center justify-end"><a href="https://accounts.lambdatest.com/login" class="desktop:block desktop:mt-10 nav-link inline-block py-8 mr-30 desktop:mr-0 text-size-16 font-medium text-ltBlack-50 desktop:text-center desktop:py-10 desktop:rounded rounded login">Login</a><div class=""><button class="desktop:block xlm:w-140 xl:w-120 w-110 desktop:w-full text-center inline-block py-8 xl:text-size-16 lg:text-size-10 font-medium text-ltBlack-50 desktop:py-10 desktop:rounded demo_header_btn desktop:text-center focus:outline-none header_gdbd overflow-hidden relative">Book a Demo</button></div><div id="m_class" class="overlay header_demo "><div class="content"><div class="demo heade xxxl:w-5/12 lg:w-6/12 md:w-8/12 w-11/12 bg-white xxl:py-35 xxl:px-45 py-20 px-30 rounded-xl shadow-lg mx-auto"><div class="contact-form contact__form"><h2 class="flex items-center justify-between xxl:text-size-28 text-size-24 text-ltBlack-400 font-bold mb-10 xxl:mb-50 relative">Schedule Your Personal Demo <span class="cursor-pointer close text-gray-240 text-size-30 font-normal">×</span></h2><form id="demoForm"><div class="grid grid-cols-2 gap-20"><div class="form-group relative mb-10 xxl:mb-30"><input type="text" id="inputFirstName" name="first_name" class="form-control shadow-none text-size-12 px-35 h-45 block w-full text-gray-80 input-lg" placeholder="First Name*" required=""/></div><div class="form-group relative mb-10 xxl:mb-30"><input type="text" id="inputLastName" name="last_name" class="form-control shadow-none text-size-12 px-35 h-45 block w-full text-gray-80 input-lg" placeholder="Last Name*" required=""/></div></div><div class="form-group relative mb-10 xxl:mb-30"><input type="email" id="inputEmail" name="email" class="form-control shadow-none text-size-12 px-35 h-45 block w-full text-gray-80 input-lg" placeholder="Work Email*" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$" required=""/></div><div class="grid grid-cols-3 gap-20 mb-10 xxl:mb-30"><div class="form-group dropdown col-span-1"/><div class="form-group relative col-span-2"><input type="tel" id="mobileid" name="mobile_no" class="form-control shadow-none text-size-12 px-35 h-45 block w-full text-gray-80" placeholder="Phone Number*" pattern="\d*" maxlength="15" required=""/></div></div><div class="grid grid-cols-3 gap-20 items-baseline mb-10 xxl:mb-30 smtablet:gap-5 smtablet:my-20 text-left"><div class="form-group relative dropdown col-span-3 smtablet:col-span-3"/></div><div class="form-group relative xxl:mb-30 mb-20"><textarea id="messageid" name="message" class="form-control shadow-none text-size-12 px-35 h-45 block w-full text-gray-80 py-10 demo_msg" placeholder="Your message"/></div><div class="form-group relative mb-10 text-center mt-45"><button type="submit" id="contbtn" class="w-full xxl:py-15 py-10 xxl:px-80 px-40 xxl:text-size-18 text-size-14 rounded border border-black bg-black text-white demo_btn hover:text-black hover:bg-transparent">SCHEDULE DEMO</button></div><input type="hidden" id="zc_gad" name="zc_gad" value=""/></form></div></div></div></div><a href="https://accounts.lambdatest.com/register" class="desktop:block xlm:w-150 xl:w-130 w-120 desktop:w-full text-center desktop:ml-0 desktop:mt-10 inline-block py-9 rounded xl:text-size-16 lg:text-size-10 ml-20 fromipad:ml-20 header_gdBg text-white desktop:text-center desktop:py-10 ipadpro:ml-10 signup font-semibold">Get Started Free</a></div></div></div></div></div></div></nav></header><div class="wrapper"><section class="pt-50 py-10"><div class="container__selenium"><div class="flex mb-30 border-b border-gray-1 pb-20 justify-between"><ul class="flex-wrap flex items-center text-size-16 text-ltBlack-400 font-normal CBT_breadcrumb"><li><a href="https://www.lambdatest.com/automation-testing-advisor" class="text-gray-240 xlm:text-size-16 text-size-14 break-words">Automation Advisor</a><i class="header CBT_arrow_right"/></li><li><a href="https://www.lambdatest.com/automation-testing-advisor/javascript/puppeteer" class="text-gray-240 xlm:text-size-16 text-size-14 break-words">puppeteer</a><i class="header CBT_arrow_right"/></li><li><a href="https://www.lambdatest.com/automation-testing-advisor/javascript/puppeteer-createCDPSession" class="text-gray-240 xlm:text-size-16 text-size-14 break-words">createCDPSession</a></li></ul></div><h1 class="break-words xxxl:text-size-42 xlm:text-size-38 text-size-29 text-black">How to use <span class="font-bold">createCDPSession</span> method in Puppeteer</h1><p class="break-words xxxl:text-size-18 xlm:text-size-16 text-size-14 font-normal text-black mt-10">Best JavaScript code snippet using <a href="https://www.lambdatest.com/automation-testing-advisor/javascript/puppeteer" class="hover:text-blue-700 underline ">puppeteer</a></p><div class="flex flex-wrap"><div class="xl:w-8/12 w-full"><div><div><div class="selenium_code_block js_code_block border border-lambda-40 rounded-md my-30 relative"><div class="flex flex-wrap items-center py-15 px-20 border-b border-lambda-40"><p class="w-7/12 smtablet:w-full xxl:text-size-17 text-size-14 font-light text-black">withDevice.js</p><p class="flex flex-wrap items-center md:justify-end w-5/12 smtablet:w-full smtablet:text-left xxl:text-size-17 text-size-14 font-light text-black text-right italic">Source:<span class="not-italic text-gray-80 ml-5 flex items-center">withDevice.js</span> <span> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/github.svg" class="w-20 ml-10" alt="Github" width="31" height="30"/></span></p></div><div class="copy_code_snippet"><div class="w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/copy.svg" class="w-20 ml-10" alt="copy" width="18" height="18"/></div></div><p class="bg-black text-white py-15 px-30 rounded-lg inline-block xxl:text-size-20 text-size-18 copy_code_done hidden"/><div class="box_s"><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/top_arrow.svg" class="w-16 mx-auto pt-5" alt="Full Screen" width="16" height="16"/></p><div class="CodeHighlighter"><code class="block"><span class="block code_snippet_line"><b class="code_snippet_line_number code_snippet_dot_dot_dot">...</b></span><span class="block code_snippet_line"><b class="code_snippet_line_number">54</b><span><span class="">};</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">55</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">56</b><span><span class=""> const browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">57</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">58</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">59</b><span><span class=""> await client.send('Network.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">60</b><span><span class=""> await client.send('Network.emulateNetworkConditions', NETWORK_PRESETS['Regular2G']);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">61</b><span><span class=""> await page.goto(WEB);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">62</b><span><span class=""> const performanceTiming = JSON.parse(</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">63</b><span><span class=""> await page.evaluate(() => JSON.stringify(window.performance.timing))</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">64</b><span><span class=""> );</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">65</b><span><span class=""> const loadWithDOM = performanceTiming.domComplete - performanceTiming.navigationStart;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">66</b><span><span class=""> const all = performanceTiming.loadEventEnd - performanceTiming.navigationStart;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">67</b><span><span class=""> console.log('User can see content for Regular2G ~', loadWithDOM / 1000, 'sec');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">68</b><span><span class=""> console.log('All Load for Regular2G --', all / 1000, 'sec');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">69</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">70</b><span><span class="">})();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">71</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">72</b><span><span class=""> const browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">73</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">74</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">75</b><span><span class=""> await client.send('Network.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">76</b><span><span class=""> await client.send('Network.emulateNetworkConditions', NETWORK_PRESETS['WiFi']);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">77</b><span><span class=""> await page.goto(WEB);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">78</b><span><span class=""> const performanceTimingFast = JSON.parse(</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">79</b><span><span class=""> await page.evaluate(() => JSON.stringify(window.performance.timing))</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">80</b><span><span class=""> );</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">81</b><span><span class=""> const loadWithDOMFast = performanceTimingFast.domComplete - performanceTimingFast.navigationStart;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">82</b><span><span class=""> const allFast = performanceTimingFast.loadEventEnd - performanceTimingFast.navigationStart;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">83</b><span><span class=""> console.log('User can see content with WiFi ~', loadWithDOMFast / 1000, 'sec');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">84</b><span><span class=""> console.log('All Load with WiFi --', allFast / 1000, 'sec');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">85</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">86</b><span><span class="">})();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">87</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">88</b><span><span class=""> const browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">89</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">90</b><span><span class=""> await page.emulate(iPhonex);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">91</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">92</b><span><span class=""> await client.send('Network.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">93</b><span><span class=""> await client.send('Network.emulateNetworkConditions', NETWORK_PRESETS['WiFi']);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">94</b><span><span class=""> await page.goto(WEB);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">95</b><span><span class=""> const performanceTimingFast = JSON.parse(</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">96</b><span><span class=""> await page.evaluate(() => JSON.stringify(window.performance.timing))</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">97</b><span><span class=""> );</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">98</b><span><span class=""> const loadWithDOMFast = performanceTimingFast.domComplete - performanceTimingFast.navigationStart;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">99</b><span><span class=""> const allFast = performanceTimingFast.loadEventEnd - performanceTimingFast.navigationStart;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">100</b><span><span class=""> console.log('[iPhone X] User can see content with WiFi ~', loadWithDOMFast / 1000, 'sec');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">101</b><span><span class=""> console.log('[iPhone X] All Load with WiFi --', allFast / 1000, 'sec');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">102</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number code_snippet_dot_dot_dot">...</b></span></code></div><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/bottom_arrow.svg" class="w-16 mx-auto pb-5" alt="Full Screen" width="16" height="16"/></p></div><div class="s__code__block smtablet:hidden tracking-wider flex items-start leading-relaxed hover:underline text-size-12 font-normal text-gray-800"><div class="f_screen w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><span> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/fullscreen.svg" class="w-16" alt="Full Screen" width="16" height="16"/></span></div></div></div><div class="selenium_code_block js_code_block border border-lambda-40 rounded-md my-30 relative"><div class="flex flex-wrap items-center py-15 px-20 border-b border-lambda-40"><p class="w-7/12 smtablet:w-full xxl:text-size-17 text-size-14 font-light text-black">CDPSession.spec.js</p><p class="flex flex-wrap items-center md:justify-end w-5/12 smtablet:w-full smtablet:text-left xxl:text-size-17 text-size-14 font-light text-black text-right italic">Source:<span class="not-italic text-gray-80 ml-5 flex items-center">CDPSession.spec.js</span> <span> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/github.svg" class="w-20 ml-10" alt="Github" width="31" height="30"/></span></p></div><div class="copy_code_snippet"><div class="w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/copy.svg" class="w-20 ml-10" alt="copy" width="18" height="18"/></div></div><p class="bg-black text-white py-15 px-30 rounded-lg inline-block xxl:text-size-20 text-size-18 copy_code_done hidden"/><div class="box_s"><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/top_arrow.svg" class="w-16 mx-auto pt-5" alt="Full Screen" width="16" height="16"/></p><div class="CodeHighlighter"><code class="block"><span class="block code_snippet_line"><b class="code_snippet_line_number code_snippet_dot_dot_dot">...</b></span><span class="block code_snippet_line"><b class="code_snippet_line_number">24</b><span><span class=""> setupTestBrowserHooks();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">25</b><span><span class=""> setupTestPageAndContextHooks();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">26</b><span><span class=""> it('should work', async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">27</b><span><span class=""> const { page } = getTestState();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">28</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">29</b><span><span class=""> await Promise.all([</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">30</b><span><span class=""> client.send('Runtime.enable'),</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">31</b><span><span class=""> client.send('Runtime.evaluate', { expression: 'window.foo = "bar"' }),</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">32</b><span><span class=""> ]);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">33</b><span><span class=""> const foo = await page.evaluate(() => window.foo);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">34</b><span><span class=""> expect(foo).toBe('bar');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">35</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">36</b><span><span class=""> it('should send events', async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">37</b><span><span class=""> const { page, server } = getTestState();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">38</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">39</b><span><span class=""> await client.send('Network.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">40</b><span><span class=""> const events = [];</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">41</b><span><span class=""> client.on('Network.requestWillBeSent', (event) => events.push(event));</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">42</b><span><span class=""> await page.goto(server.EMPTY_PAGE);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">43</b><span><span class=""> expect(events.length).toBe(1);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">44</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">45</b><span><span class=""> it('should enable and disable domains independently', async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">46</b><span><span class=""> const { page } = getTestState();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">47</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">48</b><span><span class=""> await client.send('Runtime.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">49</b><span><span class=""> await client.send('Debugger.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">50</b><span><span class=""> // JS coverage enables and then disables Debugger domain.</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">51</b><span><span class=""> await page.coverage.startJSCoverage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">52</b><span><span class=""> await page.coverage.stopJSCoverage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">53</b><span><span class=""> // generate a script in page and wait for the event.</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">54</b><span><span class=""> const [event] = await Promise.all([</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">55</b><span><span class=""> waitEvent(client, 'Debugger.scriptParsed'),</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">56</b><span><span class=""> page.evaluate('//# sourceURL=foo.js'),</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">57</b><span><span class=""> ]);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">58</b><span><span class=""> // expect events to be dispatched.</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">59</b><span><span class=""> expect(event.url).toBe('foo.js');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">60</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">61</b><span><span class=""> it('should be able to detach session', async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">62</b><span><span class=""> const { page } = getTestState();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">63</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">64</b><span><span class=""> await client.send('Runtime.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">65</b><span><span class=""> const evalResponse = await client.send('Runtime.evaluate', {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">66</b><span><span class=""> expression: '1 + 2',</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">67</b><span><span class=""> returnByValue: true,</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">68</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">69</b><span><span class=""> expect(evalResponse.result.value).toBe(3);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">70</b><span><span class=""> await client.detach();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">71</b><span><span class=""> let error = null;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">72</b><span><span class=""> try {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">73</b><span><span class=""> await client.send('Runtime.evaluate', {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">74</b><span><span class=""> expression: '3 + 1',</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">75</b><span><span class=""> returnByValue: true,</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">76</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">77</b><span><span class=""> } catch (error_) {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">78</b><span><span class=""> error = error_;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">79</b><span><span class=""> }</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">80</b><span><span class=""> expect(error.message).toContain('Session closed.');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">81</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">82</b><span><span class=""> it('should throw nice errors', async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">83</b><span><span class=""> const { page } = getTestState();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">84</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">85</b><span><span class=""> const error = await theSourceOfTheProblems().catch((error) => error);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">86</b><span><span class=""> expect(error.stack).toContain('theSourceOfTheProblems');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">87</b><span><span class=""> expect(error.message).toContain('ThisCommand.DoesNotExist');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">88</b><span><span class=""> async function theSourceOfTheProblems() {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">89</b><span><span class=""> await client.send('ThisCommand.DoesNotExist');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">90</b><span><span class=""> }</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">91</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number code_snippet_dot_dot_dot">...</b></span></code></div><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/bottom_arrow.svg" class="w-16 mx-auto pb-5" alt="Full Screen" width="16" height="16"/></p></div><div class="s__code__block smtablet:hidden tracking-wider flex items-start leading-relaxed hover:underline text-size-12 font-normal text-gray-800"><div class="f_screen w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><span> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/fullscreen.svg" class="w-16" alt="Full Screen" width="16" height="16"/></span></div></div></div><div class="selenium_code_block js_code_block border border-lambda-40 rounded-md my-30 relative"><div class="flex flex-wrap items-center py-15 px-20 border-b border-lambda-40"><p class="w-7/12 smtablet:w-full xxl:text-size-17 text-size-14 font-light text-black">CDPSession.js</p><p class="flex flex-wrap items-center md:justify-end w-5/12 smtablet:w-full smtablet:text-left xxl:text-size-17 text-size-14 font-light text-black text-right italic">Source:<span class="not-italic text-gray-80 ml-5 flex items-center">CDPSession.js</span> <span> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/github.svg" class="w-20 ml-10" alt="Github" width="31" height="30"/></span></p></div><div class="copy_code_snippet"><div class="w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/copy.svg" class="w-20 ml-10" alt="copy" width="18" height="18"/></div></div><p class="bg-black text-white py-15 px-30 rounded-lg inline-block xxl:text-size-20 text-size-18 copy_code_done hidden"/><div class="box_s"><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/top_arrow.svg" class="w-16 mx-auto pt-5" alt="Full Screen" width="16" height="16"/></p><div class="CodeHighlighter"><code class="block"><span class="block code_snippet_line"><b class="code_snippet_line_number code_snippet_dot_dot_dot">...</b></span><span class="block code_snippet_line"><b class="code_snippet_line_number">17</b><span><span class=""> await helper.end()</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">18</b><span><span class="">})</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">19</b><span><span class="">test.serial('Target.</span><mark class="YourHighlightClass ">createCDPSession</mark><span class=""> should work', async t => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">20</b><span><span class=""> const { page, server } = t.context</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">21</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">()</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">22</b><span><span class=""> await Promise.all([</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">23</b><span><span class=""> client.send('Runtime.enable'),</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">24</b><span><span class=""> client.send('Runtime.evaluate', { expression: 'window.foo = "bar"' })</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">25</b><span><span class=""> ])</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">26</b><span><span class=""> const foo = await page.evaluate(() => window.foo)</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">27</b><span><span class=""> t.is(foo, 'bar')</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">28</b><span><span class="">})</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">29</b><span><span class="">test.serial('Target.</span><mark class="YourHighlightClass ">createCDPSession</mark><span class=""> should send events', async t => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">30</b><span><span class=""> const { page, server } = t.context</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">31</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">()</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">32</b><span><span class=""> await client.send('Network.enable')</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">33</b><span><span class=""> const events = []</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">34</b><span><span class=""> client.on('Network.requestWillBeSent', event => events.push(event))</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">35</b><span><span class=""> await page.goto(server.EMPTY_PAGE)</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">36</b><span><span class=""> t.is(events.length, 1)</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">37</b><span><span class="">})</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">38</b><span><span class="">test.serial(</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">39</b><span><span class=""> 'Target.</span><mark class="YourHighlightClass ">createCDPSession</mark><span class=""> should enable and disable domains independently',</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">40</b><span><span class=""> async t => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">41</b><span><span class=""> const { page, server } = t.context</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">42</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">()</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">43</b><span><span class=""> await client.send('Runtime.enable')</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">44</b><span><span class=""> await client.send('Debugger.enable')</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">45</b><span><span class=""> // JS coverage enables and then disables Debugger domain.</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">46</b><span><span class=""> await page.coverage.startJSCoverage()</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">47</b><span><span class=""> await page.coverage.stopJSCoverage()</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">48</b><span><span class=""> // generate a script in page and wait for the event.</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">49</b><span><span class=""> const script = '() => it'</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">50</b><span><span class=""> const [event] = await Promise.all([</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">51</b><span><span class=""> waitEvent(client, 'Debugger.scriptParsed'),</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">52</b><span><span class=""> page.evaluate(script)</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">53</b><span><span class=""> ])</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">54</b><span><span class=""> // expect events to be dispatched.</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">55</b><span><span class=""> t.truthy(event)</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">56</b><span><span class=""> }</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">57</b><span><span class="">)</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">58</b><span><span class="">test.serial(</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">59</b><span><span class=""> 'Target.</span><mark class="YourHighlightClass ">createCDPSession</mark><span class=""> should be able to detach session',</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">60</b><span><span class=""> async t => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">61</b><span><span class=""> const { page, server } = t.context</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">62</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">()</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">63</b><span><span class=""> await client.send('Runtime.enable')</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">64</b><span><span class=""> const evalResponse = await client.send('Runtime.evaluate', {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">65</b><span><span class=""> expression: '1 + 2',</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">66</b><span><span class=""> returnByValue: true</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">67</b><span><span class=""> })</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">68</b><span><span class=""> t.is(evalResponse.result.value, 3)</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">69</b><span><span class=""> await client.detach()</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">70</b><span><span class=""> let error = null</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">71</b><span><span class=""> try {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">72</b><span><span class=""> await client.send('Runtime.evaluate', {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">73</b><span><span class=""> expression: '3 + 1',</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">74</b><span><span class=""> returnByValue: true</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">75</b><span><span class=""> })</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">76</b><span><span class=""> } catch (e) {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">77</b><span><span class=""> error = e</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">78</b><span><span class=""> }</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">79</b><span><span class=""> t.true(error.message.includes('Session closed.'))</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">80</b><span><span class=""> }</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">81</b><span><span class="">)</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">82</b><span><span class="">test.serial('Target.</span><mark class="YourHighlightClass ">createCDPSession</mark><span class=""> should throw nice errors', async t => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">83</b><span><span class=""> const { page } = t.context</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">84</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">()</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">85</b><span><span class=""> const error = await theSourceOfTheProblems().catch(error => error)</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">86</b><span><span class=""> t.true(error.stack.includes('theSourceOfTheProblems'))</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">87</b><span><span class=""> t.true(error.message.includes('ThisCommand.DoesNotExist'))</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">88</b><span><span class=""> async function theSourceOfTheProblems () {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">89</b><span><span class=""> await client.send('ThisCommand.DoesNotExist')</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">90</b><span><span class=""> }</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number code_snippet_dot_dot_dot">...</b></span></code></div><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/bottom_arrow.svg" class="w-16 mx-auto pb-5" alt="Full Screen" width="16" height="16"/></p></div><div class="s__code__block smtablet:hidden tracking-wider flex items-start leading-relaxed hover:underline text-size-12 font-normal text-gray-800"><div class="f_screen w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><span> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/fullscreen.svg" class="w-16" alt="Full Screen" width="16" height="16"/></span></div></div></div><div class="selenium_code_block js_code_block border border-lambda-40 rounded-md my-30 relative"><div class="flex flex-wrap items-center py-15 px-20 border-b border-lambda-40"><p class="w-7/12 smtablet:w-full xxl:text-size-17 text-size-14 font-light text-black">index.js</p><p class="flex flex-wrap items-center md:justify-end w-5/12 smtablet:w-full smtablet:text-left xxl:text-size-17 text-size-14 font-light text-black text-right italic">Source:<span class="not-italic text-gray-80 ml-5 flex items-center">index.js</span> <span> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/github.svg" class="w-20 ml-10" alt="Github" width="31" height="30"/></span></p></div><div class="copy_code_snippet"><div class="w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/copy.svg" class="w-20 ml-10" alt="copy" width="18" height="18"/></div></div><p class="bg-black text-white py-15 px-30 rounded-lg inline-block xxl:text-size-20 text-size-18 copy_code_done hidden"/><div class="box_s"><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/top_arrow.svg" class="w-16 mx-auto pt-5" alt="Full Screen" width="16" height="16"/></p><div class="CodeHighlighter"><code class="block"><span class="block code_snippet_line"><b class="code_snippet_line_number code_snippet_dot_dot_dot">...</b></span><span class="block code_snippet_line"><b class="code_snippet_line_number">23</b><span><span class=""> let res = [];</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">24</b><span><span class=""> // ------- first browser run ---------</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">25</b><span><span class=""> let browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">26</b><span><span class=""> let page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">27</b><span><span class=""> let client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">28</b><span><span class=""> await emulateConditions(client);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">29</b><span><span class=""> // first enter test</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">30</b><span><span class=""> res = [</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">31</b><span><span class=""> ...res,</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">32</b><span><span class=""> ...convertResultsToArr(await testPage(page, client), 'firstEnter'),</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">33</b><span><span class=""> ];</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">34</b><span><span class=""> bar.tick();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">35</b><span><span class=""> await page.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">36</b><span><span class=""> page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">37</b><span><span class=""> client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">38</b><span><span class=""> await emulateConditions(client);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">39</b><span><span class=""> // second enter test with ServiceWorker and cache</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">40</b><span><span class=""> res = [</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">41</b><span><span class=""> ...res,</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">42</b><span><span class=""> ...convertResultsToArr(await testPage(page, client), 'swAndCache'),</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">43</b><span><span class=""> ];</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">44</b><span><span class=""> bar.tick();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">45</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">46</b><span><span class=""> // ------- second browser run ---------</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">47</b><span><span class=""> browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">48</b><span><span class=""> page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">49</b><span><span class=""> client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">50</b><span><span class=""> // first enter only for hydration ServiceWorker and cache</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">51</b><span><span class=""> await testPage(page, client);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">52</b><span><span class=""> bar.tick();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">53</b><span><span class=""> await page.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">54</b><span><span class=""> page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">55</b><span><span class=""> client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">56</b><span><span class=""> await emulateConditions(client);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">57</b><span><span class=""> await client.send('ServiceWorker.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">58</b><span><span class=""> await client.send('ServiceWorker.unregister', {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">59</b><span><span class=""> scopeURL: 'http://localhost:8080/',</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">60</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">61</b><span><span class=""> // second enter test with cache</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">62</b><span><span class=""> res = [</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">63</b><span><span class=""> ...res,</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">64</b><span><span class=""> ...convertResultsToArr(await testPage(page, client), 'cache'),</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">65</b><span><span class=""> ];</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">66</b><span><span class=""> bar.tick();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">67</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">68</b><span><span class=""> // ------- third browser run ---------</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">69</b><span><span class=""> browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">70</b><span><span class=""> page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">71</b><span><span class=""> client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">72</b><span><span class=""> // first enter only for hydration ServiceWorker and cache</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">73</b><span><span class=""> await testPage(page, client);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">74</b><span><span class=""> bar.tick();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">75</b><span><span class=""> await page.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">76</b><span><span class=""> page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">77</b><span><span class=""> client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">78</b><span><span class=""> await emulateConditions(client);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">79</b><span><span class=""> await client.send('Network.clearBrowserCache');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">80</b><span><span class=""> // second enter test with ServiceWorker</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">81</b><span><span class=""> res = [...res, ...convertResultsToArr(await testPage(page, client), 'sw')];</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">82</b><span><span class=""> bar.tick();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">83</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">84</b><span><span class=""> const file = JSON.parse(await promisify(fs.readFile)(filePath));</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">85</b><span><span class=""> await promisify(fs.writeFile)(filePath, JSON.stringify([...file, ...res]));</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">86</b><span><span class=""> }</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">87</b><span><span class="">};</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number code_snippet_dot_dot_dot">...</b></span></code></div><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/bottom_arrow.svg" class="w-16 mx-auto pb-5" alt="Full Screen" width="16" height="16"/></p></div><div class="s__code__block smtablet:hidden tracking-wider flex items-start leading-relaxed hover:underline text-size-12 font-normal text-gray-800"><div class="f_screen w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><span> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/fullscreen.svg" class="w-16" alt="Full Screen" width="16" height="16"/></span></div></div></div><div class="selenium_code_block js_code_block border border-lambda-40 rounded-md my-30 relative"><div class="flex flex-wrap items-center py-15 px-20 border-b border-lambda-40"><p class="w-7/12 smtablet:w-full xxl:text-size-17 text-size-14 font-light text-black">connect_to_browser.js</p><p class="flex flex-wrap items-center md:justify-end w-5/12 smtablet:w-full smtablet:text-left xxl:text-size-17 text-size-14 font-light text-black text-right italic">Source:<span class="not-italic text-gray-80 ml-5 flex items-center">connect_to_browser.js</span> <span> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/github.svg" class="w-20 ml-10" alt="Github" width="31" height="30"/></span></p></div><div class="copy_code_snippet"><div class="w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/copy.svg" class="w-20 ml-10" alt="copy" width="18" height="18"/></div></div><p class="bg-black text-white py-15 px-30 rounded-lg inline-block xxl:text-size-20 text-size-18 copy_code_done hidden"/><div class="box_s"><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/top_arrow.svg" class="w-16 mx-auto pt-5" alt="Full Screen" width="16" height="16"/></p><div class="CodeHighlighter"><code class="block"><span class="block code_snippet_line"><b class="code_snippet_line_number code_snippet_dot_dot_dot">...</b></span><span class="block code_snippet_line"><b class="code_snippet_line_number">11</b><span><span class=""> </span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">12</b><span><span class=""> browser.on('targetchanged', async (target) => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">13</b><span><span class=""> if (target.type() === 'page') {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">14</b><span><span class=""> console.log('\n[targetchanged event]\n');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">15</b><span><span class=""> let cdp = await target.</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">16</b><span><span class=""> var page = await target.page();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">17</b><span><span class=""> </span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">18</b><span><span class=""> serve_history_page(cdp);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">19</b><span><span class=""> runPageOperations(page, cdp);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">20</b><span><span class=""> }</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">21</b><span><span class=""> })</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">22</b><span><span class=""> //Get tagets for tabs opened in the background</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">23</b><span><span class=""> // ex: tabs that are opened by middle click</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">24</b><span><span class=""> browser.on('targetcreated', async (target) => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">25</b><span><span class=""> if (target.type() === 'page') {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">26</b><span><span class=""> console.log('\nnew tab opened\n');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">27</b><span><span class=""> let cdp = await target.</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">28</b><span><span class=""> var page = await target.page();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">29</b><span><span class=""> </span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">30</b><span><span class=""> serve_history_page(cdp);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">31</b><span><span class=""> runPageOperations(page, cdp);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">32</b><span><span class=""> }</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">33</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">34</b><span><span class=""> //TODO make sure to on the run these functions ^ single</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">35</b><span><span class=""> //Make a test to see if the page target is already being handled </span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">36</b><span><span class=""> </span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">37</b><span><span class=""> const pages = (await browser.pages());</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">38</b><span><span class=""> console.log('open pages:');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">39</b><span><span class=""> console.log(pages.length);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">40</b><span><span class=""> var cdp = await pages[0].target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">41</b><span><span class=""> var targets = await cdp.send('Target.getTargets');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">42</b><span><span class=""> console.log('targets:');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">43</b><span><span class=""> console.log(targets['targetInfos'].length);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">44</b><span><span class=""> var attached_targets = 0;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">45</b><span><span class=""> targets['targetInfos'].forEach(async (target) => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">46</b><span><span class=""> if (target['attached'] == true)</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">47</b><span><span class=""> {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">48</b><span><span class=""> attached_targets++;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">49</b><span><span class=""> }</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">50</b><span><span class=""> })</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">51</b><span><span class=""> console.log('attached targets:');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">52</b><span><span class=""> console.log(attached_targets);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">53</b><span><span class=""> // Handle when the page gets closed suddenly</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">54</b><span><span class=""> process.on('unhandledRejection', (reason) => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number code_snippet_dot_dot_dot">...</b></span></code></div><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/bottom_arrow.svg" class="w-16 mx-auto pb-5" alt="Full Screen" width="16" height="16"/></p></div><div class="s__code__block smtablet:hidden tracking-wider flex items-start leading-relaxed hover:underline text-size-12 font-normal text-gray-800"><div class="f_screen w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><span> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/fullscreen.svg" class="w-16" alt="Full Screen" width="16" height="16"/></span></div></div></div><div class="selenium_code_block js_code_block border border-lambda-40 rounded-md my-30 relative"><div class="flex flex-wrap items-center py-15 px-20 border-b border-lambda-40"><p class="w-7/12 smtablet:w-full xxl:text-size-17 text-size-14 font-light text-black">clearData.js</p><p class="flex flex-wrap items-center md:justify-end w-5/12 smtablet:w-full smtablet:text-left xxl:text-size-17 text-size-14 font-light text-black text-right italic">Source:<span class="not-italic text-gray-80 ml-5 flex items-center">clearData.js</span> <span> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/github.svg" class="w-20 ml-10" alt="Github" width="31" height="30"/></span></p></div><div class="copy_code_snippet"><div class="w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/copy.svg" class="w-20 ml-10" alt="copy" width="18" height="18"/></div></div><p class="bg-black text-white py-15 px-30 rounded-lg inline-block xxl:text-size-20 text-size-18 copy_code_done hidden"/><div class="box_s"><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/top_arrow.svg" class="w-16 mx-auto pt-5" alt="Full Screen" width="16" height="16"/></p><div class="CodeHighlighter"><code class="block"><span class="block code_snippet_line"><b class="code_snippet_line_number code_snippet_dot_dot_dot">...</b></span><span class="block code_snippet_line"><b class="code_snippet_line_number">6</b><span><span class=""> await waitFor(</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">7</b><span><span class=""> async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">8</b><span><span class=""> let closeCdpSession = false;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">9</b><span><span class=""> if (!cdpSession) {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">10</b><span><span class=""> cdpSession = await this.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">11</b><span><span class=""> closeCdpSession = true;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">12</b><span><span class=""> }</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">13</b><span><span class=""> await Promise.all([</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">14</b><span><span class=""> cdpSession.send('Network.clearBrowserCookies'),</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">15</b><span><span class=""> this.evaluate(() => localStorage.clear()).catch(err => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">16</b><span><span class=""> logger.warn('fail to clear localStorage', err);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">17</b><span><span class=""> }),</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">18</b><span><span class=""> this.evaluate(() => sessionStorage.clear()).catch(err => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">19</b><span><span class=""> logger.warn('fail to clear sessionStorage', err);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">20</b><span><span class=""> }),</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">21</b><span><span class=""> ]);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">22</b><span><span class=""> if (closeCdpSession) await cdpSession.detach();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">23</b><span><span class=""> },</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">24</b><span><span class=""> { timeout: 20000, message: 'unable to clear user data' },</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">25</b><span><span class=""> );</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">26</b><span><span class=""> } catch (err) {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">27</b><span><span class=""> err.message = `failed to clear user data.\n${err.message}`;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">28</b><span><span class=""> logger.error(err);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">29</b><span><span class=""> throw err;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">30</b><span><span class=""> }</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">31</b><span><span class="">}</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">32</b><span><span class="">async function clearCache(cdpSession = null) {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">33</b><span><span class=""> try {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">34</b><span><span class=""> if (!cdpSession) cdpSession = await this.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">35</b><span><span class=""> // Wipe entire disk cache</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">36</b><span><span class=""> await cdpSession.send('Network.clearBrowserCache');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">37</b><span><span class=""> // Toggle 'Disable Cache' to evict the memory cache</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">38</b><span><span class=""> await cdpSession.send('Network.setCacheDisabled', { cacheDisabled: true });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">39</b><span><span class=""> await cdpSession.send('Network.setCacheDisabled', { cacheDisabled: false });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">40</b><span><span class=""> } catch (err) {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">41</b><span><span class=""> err.message = `failed to clear user cache.\n${err.message}`;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">42</b><span><span class=""> logger.error(err);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">43</b><span><span class=""> throw err;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">44</b><span><span class=""> }</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">45</b><span><span class="">}</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">46</b><span><span class="">async function clearAllData() {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">47</b><span><span class=""> const cdpSession = await this.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">48</b><span><span class=""> await Promise.all([</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">49</b><span><span class=""> this.clearCache(cdpSession),</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">50</b><span><span class=""> this.clearUserData(cdpSession),</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">51</b><span><span class=""> cdpSession.send('Storage.clearDataForOrigin', {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">52</b><span><span class=""> origin: new URL(url).origin,</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">53</b><span><span class=""> storageTypes: 'all',</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">54</b><span><span class=""> }),</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">55</b><span><span class=""> ]);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">56</b><span><span class=""> await cdpSession.detach();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">57</b><span><span class="">}</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">58</b><span><span class="">module.exports = {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">59</b><span><span class=""> clearUserData,</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">60</b><span><span class=""> clearCache,</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">61</b><span><span class=""> clearAllData,</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number code_snippet_dot_dot_dot">...</b></span></code></div><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/bottom_arrow.svg" class="w-16 mx-auto pb-5" alt="Full Screen" width="16" height="16"/></p></div><div class="s__code__block smtablet:hidden tracking-wider flex items-start leading-relaxed hover:underline text-size-12 font-normal text-gray-800"><div class="f_screen w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><span> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/fullscreen.svg" class="w-16" alt="Full Screen" width="16" height="16"/></span></div></div></div><div class="selenium_code_block js_code_block border border-lambda-40 rounded-md my-30 relative"><div class="flex flex-wrap items-center py-15 px-20 border-b border-lambda-40"><p class="w-7/12 smtablet:w-full xxl:text-size-17 text-size-14 font-light text-black">test.js</p><p class="flex flex-wrap items-center md:justify-end w-5/12 smtablet:w-full smtablet:text-left xxl:text-size-17 text-size-14 font-light text-black text-right italic">Source:<span class="not-italic text-gray-80 ml-5 flex items-center">test.js</span> <span> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/github.svg" class="w-20 ml-10" alt="Github" width="31" height="30"/></span></p></div><div class="copy_code_snippet"><div class="w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/copy.svg" class="w-20 ml-10" alt="copy" width="18" height="18"/></div></div><p class="bg-black text-white py-15 px-30 rounded-lg inline-block xxl:text-size-20 text-size-18 copy_code_done hidden"/><div class="box_s"><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/top_arrow.svg" class="w-16 mx-auto pt-5" alt="Full Screen" width="16" height="16"/></p><div class="CodeHighlighter"><code class="block"><span class="block code_snippet_line"><b class="code_snippet_line_number">1</b><span><span class="">const EventEmitter = require('events');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">2</b><span><span class="">const test = require('tape');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">3</b><span><span class="">const {stub} = require('sinon');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">4</b><span><span class="">test('PuppeteerNetworkStats', async (t) => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">5</b><span><span class=""> t.plan(6);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">6</b><span><span class=""> const PuppeteerNetworkStats = require('./index');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">7</b><span><span class=""> const mockClient = new EventEmitter();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">8</b><span><span class=""> mockClient.send = stub();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">9</b><span><span class=""> mockClient.detach = stub();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">10</b><span><span class=""> const </span><mark class="YourHighlightClass ">createCDPSession</mark><span class=""> = stub().returns(mockClient);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">11</b><span><span class=""> const mockPage = {target: () => ({</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">})};</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">12</b><span><span class=""> const networkStats = new PuppeteerNetworkStats({</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">13</b><span><span class=""> requestWillBeSent: ({request: {url}}) => ({url}),</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">14</b><span><span class=""> responseReceived: ({response: {status}}) => ({status})</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">15</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">16</b><span><span class=""> await networkStats.attach(mockPage);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">17</b><span><span class=""> t.ok(</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">18</b><span><span class=""> </span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">.calledOnce,</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">19</b><span><span class=""> 'attach creates client'</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">20</b><span><span class=""> );</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">21</b><span><span class=""> t.ok(</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">22</b><span><span class=""> mockClient.send.calledWith('Network.enable'),</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">23</b><span><span class=""> 'attach enables Network'</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">24</b><span><span class=""> );</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">25</b><span><span class=""> const id = 1;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">26</b><span><span class=""> const url = 'https://www.example.com';</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">27</b><span><span class=""> mockClient.emit(</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">28</b><span><span class=""> 'Network.requestWillBeSent',</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">29</b><span><span class=""> {requestId: id, request: {url}}</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">30</b><span><span class=""> );</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">31</b><span><span class=""> t.equal(</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">32</b><span><span class=""> networkStats.getRequests()[id].url, url,</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">33</b><span><span class=""> 'configured parameters are captured from an event'</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">34</b><span><span class=""> );</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">35</b><span><span class=""> const status = 200;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">36</b><span><span class=""> mockClient.emit(</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">37</b><span><span class=""> 'Network.responseReceived',</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">38</b><span><span class=""> {requestId: id, response: {status}}</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">39</b><span><span class=""> );</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">40</b><span><span class=""> t.deepEqual(</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">41</b><span><span class=""> networkStats.getRequests()[id], {status, url},</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">42</b><span><span class=""> 'event with same request id has its captured parameters merged'</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">43</b><span><span class=""> );</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">44</b><span><span class=""> await networkStats.detach(mockPage);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">45</b><span><span class=""> t.ok(mockClient.detach.calledOnce, 'detach calls client.detach');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">46</b><span><span class=""> networkStats.clearRequests();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">47</b><span><span class=""> t.deepEqual(</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">48</b><span><span class=""> networkStats.getRequests(), {},</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">49</b><span><span class=""> 'clearRequests clears captured requests'</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">50</b><span><span class=""> );</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number code_snippet_dot_dot_dot">...</b></span></code></div><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/bottom_arrow.svg" class="w-16 mx-auto pb-5" alt="Full Screen" width="16" height="16"/></p></div><div class="s__code__block smtablet:hidden tracking-wider flex items-start leading-relaxed hover:underline text-size-12 font-normal text-gray-800"><div class="f_screen w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><span> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/fullscreen.svg" class="w-16" alt="Full Screen" width="16" height="16"/></span></div></div></div><div class="selenium_code_block js_code_block border border-lambda-40 rounded-md my-30 relative"><div class="flex flex-wrap items-center py-15 px-20 border-b border-lambda-40"><p class="w-7/12 smtablet:w-full xxl:text-size-17 text-size-14 font-light text-black">util.js</p><p class="flex flex-wrap items-center md:justify-end w-5/12 smtablet:w-full smtablet:text-left xxl:text-size-17 text-size-14 font-light text-black text-right italic">Source:<span class="not-italic text-gray-80 ml-5 flex items-center">util.js</span> <span> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/github.svg" class="w-20 ml-10" alt="Github" width="31" height="30"/></span></p></div><div class="copy_code_snippet"><div class="w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/copy.svg" class="w-20 ml-10" alt="copy" width="18" height="18"/></div></div><p class="bg-black text-white py-15 px-30 rounded-lg inline-block xxl:text-size-20 text-size-18 copy_code_done hidden"/><div class="box_s"><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/top_arrow.svg" class="w-16 mx-auto pt-5" alt="Full Screen" width="16" height="16"/></p><div class="CodeHighlighter"><code class="block"><span class="block code_snippet_line"><b class="code_snippet_line_number">1</b><span><span class="">async function minimize(page) {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">2</b><span><span class=""> const session = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">3</b><span><span class=""> const goods = await session.send("Browser.getWindowForTarget");</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">4</b><span><span class=""> const { windowId } = goods;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">5</b><span><span class=""> await session.send("Browser.setWindowBounds", {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">6</b><span><span class=""> windowId,</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">7</b><span><span class=""> bounds: { windowState: "minimized" },</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">8</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">9</b><span><span class=""> </span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">10</b><span><span class=""> return;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">11</b><span><span class=""> }</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">12</b><span><span class=""> </span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">13</b><span><span class="">async function maximize(page) {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">14</b><span><span class=""> const session = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">15</b><span><span class=""> const goods = await session.send("Browser.getWindowForTarget");</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">16</b><span><span class=""> const { windowId } = goods;</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">17</b><span><span class=""> await session.send("Browser.setWindowBounds", {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">18</b><span><span class=""> windowId,</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">19</b><span><span class=""> bounds: { windowState: "normal" },</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">20</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">21</b><span><span class=""> }</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">22</b><span><span class="">module.exports = {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">23</b><span><span class=""> minimize,</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">24</b><span><span class=""> maximize</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number code_snippet_dot_dot_dot">...</b></span></code></div><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/bottom_arrow.svg" class="w-16 mx-auto pb-5" alt="Full Screen" width="16" height="16"/></p></div><div class="s__code__block smtablet:hidden tracking-wider flex items-start leading-relaxed hover:underline text-size-12 font-normal text-gray-800"><div class="f_screen w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><span> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/fullscreen.svg" class="w-16" alt="Full Screen" width="16" height="16"/></span></div></div></div><div class="selenium_code_block border border-lambda-40 rounded-md my-30 relative"><div class="flex smtablet:block flex-wrap justify-between items-center px-20 border-b border-lambda-40"><p class="smtablet:w-full xll:text-size-16 xl:text-size-14 text-size-12 font-medium text-black"/><p class="flex items-center md:justify-end smtablet:w-full smtablet:text-left xll:text-size-16 xl:text-size-14 text-size-12 font-normal text-right break-all copilotsnippet_css"><span class="copilot_border mr-20"/>Using AI Code Generation</p></div><div class="copy_code_snippet"><div class="w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/copy.svg" class="w-20 ml-10" alt="copy" width="18" height="18"/></div></div><p class="bg-black text-white py-15 px-30 rounded-lg inline-block xxl:text-size-20 text-size-18 copy_code_done hidden"/><div class="box_s"><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/top_arrow.svg" class="w-16 mx-auto pt-5" alt="Full Screen" width="16" height="16"/></p><div class="CodeHighlighter"><code class="block"><span class="block code_snippet_line"><b class="code_snippet_line_number">1</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">2</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">3</b><span><span class=""> const browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">4</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">5</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">6</b><span><span class=""> await client.send('Network.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">7</b><span><span class=""> await page.screenshot({path: 'example.png'});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">8</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">9</b><span><span class="">})();</span></span></span></code></div><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/bottom_arrow.svg" class="w-16 mx-auto pb-5" alt="Full Screen" width="16" height="16"/></p></div><div class="s__code__block smtablet:hidden tracking-wider flex items-start leading-relaxed hover:underline text-size-12 font-normal text-gray-800"><div class="f_screen w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><a href="https://www.lambdatest.com/automation-testing-advisor/copilotcodeviewer/?snippet=" rel="noopener noreferrer" target="_blank"> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/fullscreen.svg" class="w-16" alt="Full Screen" width="16" height="16"/></a></div></div></div><div class="selenium_code_block border border-lambda-40 rounded-md my-30 relative"><div class="flex smtablet:block flex-wrap justify-between items-center px-20 border-b border-lambda-40"><p class="smtablet:w-full xll:text-size-16 xl:text-size-14 text-size-12 font-medium text-black"/><p class="flex items-center md:justify-end smtablet:w-full smtablet:text-left xll:text-size-16 xl:text-size-14 text-size-12 font-normal text-right break-all copilotsnippet_css"><span class="copilot_border mr-20"/>Using AI Code Generation</p></div><div class="copy_code_snippet"><div class="w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/copy.svg" class="w-20 ml-10" alt="copy" width="18" height="18"/></div></div><p class="bg-black text-white py-15 px-30 rounded-lg inline-block xxl:text-size-20 text-size-18 copy_code_done hidden"/><div class="box_s"><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/top_arrow.svg" class="w-16 mx-auto pt-5" alt="Full Screen" width="16" height="16"/></p><div class="CodeHighlighter"><code class="block"><span class="block code_snippet_line"><b class="code_snippet_line_number">1</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">2</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">3</b><span><span class=""> const browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">4</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">5</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">6</b><span><span class=""> await client.send('Network.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">7</b><span><span class=""> await client.send('Network.setExtraHTTPHeaders', {headers: { 'X-My-Custom-Header': 'MyCustomHeaderValue' }});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">8</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">9</b><span><span class="">})();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">10</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">11</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">12</b><span><span class=""> const browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">13</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">14</b><span><span class=""> await page.setExtraHTTPHeaders({</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">15</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">16</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">17</b><span><span class="">})();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">18</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">19</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">20</b><span><span class=""> const browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">21</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">22</b><span><span class=""> await page.setExtraHTTPHeaders({</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">23</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">24</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">25</b><span><span class="">})();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">26</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">27</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">28</b><span><span class=""> const browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">29</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">30</b><span><span class=""> await page.setExtraHTTPHeaders({</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">31</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">32</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">33</b><span><span class="">})();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">34</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">35</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">36</b><span><span class=""> const browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">37</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">38</b><span><span class=""> await page.setExtraHTTPHeaders({</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">39</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">40</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">41</b><span><span class="">})();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">42</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span></code></div><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/bottom_arrow.svg" class="w-16 mx-auto pb-5" alt="Full Screen" width="16" height="16"/></p></div><div class="s__code__block smtablet:hidden tracking-wider flex items-start leading-relaxed hover:underline text-size-12 font-normal text-gray-800"><div class="f_screen w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><a href="https://www.lambdatest.com/automation-testing-advisor/copilotcodeviewer/?snippet=" rel="noopener noreferrer" target="_blank"> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/fullscreen.svg" class="w-16" alt="Full Screen" width="16" height="16"/></a></div></div></div><div class="selenium_code_block border border-lambda-40 rounded-md my-30 relative"><div class="flex smtablet:block flex-wrap justify-between items-center px-20 border-b border-lambda-40"><p class="smtablet:w-full xll:text-size-16 xl:text-size-14 text-size-12 font-medium text-black"/><p class="flex items-center md:justify-end smtablet:w-full smtablet:text-left xll:text-size-16 xl:text-size-14 text-size-12 font-normal text-right break-all copilotsnippet_css"><span class="copilot_border mr-20"/>Using AI Code Generation</p></div><div class="copy_code_snippet"><div class="w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/copy.svg" class="w-20 ml-10" alt="copy" width="18" height="18"/></div></div><p class="bg-black text-white py-15 px-30 rounded-lg inline-block xxl:text-size-20 text-size-18 copy_code_done hidden"/><div class="box_s"><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/top_arrow.svg" class="w-16 mx-auto pt-5" alt="Full Screen" width="16" height="16"/></p><div class="CodeHighlighter"><code class="block"><span class="block code_snippet_line"><b class="code_snippet_line_number">1</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">2</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">3</b><span><span class=""> const browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">4</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">5</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">6</b><span><span class=""> await client.send('Network.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">7</b><span><span class=""> client.on('Network.requestWillBeSent', (params) => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">8</b><span><span class=""> console.log(params.request.url);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">9</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">10</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">11</b><span><span class="">})();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">12</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">13</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">14</b><span><span class=""> const browser = await puppeteer.launch({headless: false});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">15</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">16</b><span><span class=""> await page.goto(url);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">17</b><span><span class=""> await page.waitForSelector('input[name="q"]');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">18</b><span><span class=""> await page.$eval('input[name="q"]', (el, value) => el.value = value, 'puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">19</b><span><span class=""> await page.click('input[name="btnK"]');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">20</b><span><span class=""> await page.waitForNavigation();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">21</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">22</b><span><span class="">})();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">23</b><span><span class="">const cookies = await page.cookies();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">24</b><span><span class="">console.log(cookies);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">25</b><span><span class="">const cookies = await page._client.send('Network.getAllCookies');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">26</b><span><span class="">console.log(cookies);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">27</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">28</b><span><span class="">(async () => {</span></span></span></code></div><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/bottom_arrow.svg" class="w-16 mx-auto pb-5" alt="Full Screen" width="16" height="16"/></p></div><div class="s__code__block smtablet:hidden tracking-wider flex items-start leading-relaxed hover:underline text-size-12 font-normal text-gray-800"><div class="f_screen w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><a href="https://www.lambdatest.com/automation-testing-advisor/copilotcodeviewer/?snippet=" rel="noopener noreferrer" target="_blank"> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/fullscreen.svg" class="w-16" alt="Full Screen" width="16" height="16"/></a></div></div></div><div class="selenium_code_block border border-lambda-40 rounded-md my-30 relative"><div class="flex smtablet:block flex-wrap justify-between items-center px-20 border-b border-lambda-40"><p class="smtablet:w-full xll:text-size-16 xl:text-size-14 text-size-12 font-medium text-black"/><p class="flex items-center md:justify-end smtablet:w-full smtablet:text-left xll:text-size-16 xl:text-size-14 text-size-12 font-normal text-right break-all copilotsnippet_css"><span class="copilot_border mr-20"/>Using AI Code Generation</p></div><div class="copy_code_snippet"><div class="w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/copy.svg" class="w-20 ml-10" alt="copy" width="18" height="18"/></div></div><p class="bg-black text-white py-15 px-30 rounded-lg inline-block xxl:text-size-20 text-size-18 copy_code_done hidden"/><div class="box_s"><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/top_arrow.svg" class="w-16 mx-auto pt-5" alt="Full Screen" width="16" height="16"/></p><div class="CodeHighlighter"><code class="block"><span class="block code_snippet_line"><b class="code_snippet_line_number">1</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">2</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">3</b><span><span class=""> const browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">4</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">5</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">6</b><span><span class=""> await client.send('Page.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">7</b><span><span class=""> await client.send('Page.captureScreenshot', { format: 'png', fromSurface: true })</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">8</b><span><span class=""> .then((image) => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">9</b><span><span class=""> console.log(image);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">10</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">11</b><span><span class=""> await browser.close(</span></span></span></code></div><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/bottom_arrow.svg" class="w-16 mx-auto pb-5" alt="Full Screen" width="16" height="16"/></p></div><div class="s__code__block smtablet:hidden tracking-wider flex items-start leading-relaxed hover:underline text-size-12 font-normal text-gray-800"><div class="f_screen w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><a href="https://www.lambdatest.com/automation-testing-advisor/copilotcodeviewer/?snippet=" rel="noopener noreferrer" target="_blank"> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/fullscreen.svg" class="w-16" alt="Full Screen" width="16" height="16"/></a></div></div></div><div class="selenium_code_block border border-lambda-40 rounded-md my-30 relative"><div class="flex smtablet:block flex-wrap justify-between items-center px-20 border-b border-lambda-40"><p class="smtablet:w-full xll:text-size-16 xl:text-size-14 text-size-12 font-medium text-black"/><p class="flex items-center md:justify-end smtablet:w-full smtablet:text-left xll:text-size-16 xl:text-size-14 text-size-12 font-normal text-right break-all copilotsnippet_css"><span class="copilot_border mr-20"/>Using AI Code Generation</p></div><div class="copy_code_snippet"><div class="w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/copy.svg" class="w-20 ml-10" alt="copy" width="18" height="18"/></div></div><p class="bg-black text-white py-15 px-30 rounded-lg inline-block xxl:text-size-20 text-size-18 copy_code_done hidden"/><div class="box_s"><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/top_arrow.svg" class="w-16 mx-auto pt-5" alt="Full Screen" width="16" height="16"/></p><div class="CodeHighlighter"><code class="block"><span class="block code_snippet_line"><b class="code_snippet_line_number">1</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">2</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">3</b><span><span class=""> const browser = await puppeteer.launch({headless: false});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">4</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">5</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">6</b><span><span class=""> const response = await client.send('Network.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">7</b><span><span class=""> console.log(response);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">8</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">9</b><span><span class="">})();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">10</b><span><span class="">{ id: 1, result: {} }</span></span></span></code></div><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/bottom_arrow.svg" class="w-16 mx-auto pb-5" alt="Full Screen" width="16" height="16"/></p></div><div class="s__code__block smtablet:hidden tracking-wider flex items-start leading-relaxed hover:underline text-size-12 font-normal text-gray-800"><div class="f_screen w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><a href="https://www.lambdatest.com/automation-testing-advisor/copilotcodeviewer/?snippet=" rel="noopener noreferrer" target="_blank"> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/fullscreen.svg" class="w-16" alt="Full Screen" width="16" height="16"/></a></div></div></div><div class="selenium_code_block border border-lambda-40 rounded-md my-30 relative"><div class="flex smtablet:block flex-wrap justify-between items-center px-20 border-b border-lambda-40"><p class="smtablet:w-full xll:text-size-16 xl:text-size-14 text-size-12 font-medium text-black"/><p class="flex items-center md:justify-end smtablet:w-full smtablet:text-left xll:text-size-16 xl:text-size-14 text-size-12 font-normal text-right break-all copilotsnippet_css"><span class="copilot_border mr-20"/>Using AI Code Generation</p></div><div class="copy_code_snippet"><div class="w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/copy.svg" class="w-20 ml-10" alt="copy" width="18" height="18"/></div></div><p class="bg-black text-white py-15 px-30 rounded-lg inline-block xxl:text-size-20 text-size-18 copy_code_done hidden"/><div class="box_s"><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/top_arrow.svg" class="w-16 mx-auto pt-5" alt="Full Screen" width="16" height="16"/></p><div class="CodeHighlighter"><code class="block"><span class="block code_snippet_line"><b class="code_snippet_line_number">1</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">2</b><span><span class="">const fs = require('fs');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">3</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">4</b><span><span class=""> const browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">5</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">6</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">7</b><span><span class=""> await client.send('Page.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">8</b><span><span class=""> await client.send('Page.captureScreenshot', {format: 'jpeg', fromSurface: true})</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">9</b><span><span class=""> .then(result => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">10</b><span><span class=""> fs.writeFile('screenshot.jpeg', result.data, 'base64', function (err) {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">11</b><span><span class=""> if (err) {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">12</b><span><span class=""> console.log(err);</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">13</b><span><span class=""> }</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">14</b><span><span class=""> console.log('File created');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">15</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">16</b><span><span class=""> });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">17</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">18</b><span><span class="">})();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">19</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">20</b><span><span class="">const fs = require('fs');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">21</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">22</b><span><span class=""> const browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">23</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">24</b><span><span class=""> await page.screenshot({path: 'screenshot.jpeg'});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">25</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">26</b><span><span class="">})();</span></span></span></code></div><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/bottom_arrow.svg" class="w-16 mx-auto pb-5" alt="Full Screen" width="16" height="16"/></p></div><div class="s__code__block smtablet:hidden tracking-wider flex items-start leading-relaxed hover:underline text-size-12 font-normal text-gray-800"><div class="f_screen w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><a href="https://www.lambdatest.com/automation-testing-advisor/copilotcodeviewer/?snippet=" rel="noopener noreferrer" target="_blank"> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/fullscreen.svg" class="w-16" alt="Full Screen" width="16" height="16"/></a></div></div></div><div class="selenium_code_block border border-lambda-40 rounded-md my-30 relative"><div class="flex smtablet:block flex-wrap justify-between items-center px-20 border-b border-lambda-40"><p class="smtablet:w-full xll:text-size-16 xl:text-size-14 text-size-12 font-medium text-black"/><p class="flex items-center md:justify-end smtablet:w-full smtablet:text-left xll:text-size-16 xl:text-size-14 text-size-12 font-normal text-right break-all copilotsnippet_css"><span class="copilot_border mr-20"/>Using AI Code Generation</p></div><div class="copy_code_snippet"><div class="w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/copy.svg" class="w-20 ml-10" alt="copy" width="18" height="18"/></div></div><p class="bg-black text-white py-15 px-30 rounded-lg inline-block xxl:text-size-20 text-size-18 copy_code_done hidden"/><div class="box_s"><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/top_arrow.svg" class="w-16 mx-auto pt-5" alt="Full Screen" width="16" height="16"/></p><div class="CodeHighlighter"><code class="block"><span class="block code_snippet_line"><b class="code_snippet_line_number">1</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">2</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">3</b><span><span class=""> const browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">4</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">5</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">6</b><span><span class=""> await client.send('Network.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">7</b><span><span class=""> await client.send('Network.setCacheDisabled', { cacheDisabled: true });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">8</b><span><span class=""> await page.screenshot({path: 'google.png'});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">9</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">10</b><span><span class="">})();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">11</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">12</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">13</b><span><span class=""> const browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">14</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">15</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">16</b><span><span class=""> await client.send('Network.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">17</b><span><span class=""> await client.send('Network.setCacheDisabled', { cacheDisabled: true });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">18</b><span><span class=""> await page.screenshot({path: 'google.png'});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">19</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">20</b><span><span class="">})();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">21</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">22</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">23</b><span><span class=""> const browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">24</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">25</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">26</b><span><span class=""> await client.send('Network.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">27</b><span><span class=""> await client.send('Network.setCacheDisabled', { cacheDisabled: true });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">28</b><span><span class=""> await page.screenshot({path: 'google.png'});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">29</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">30</b><span><span class="">})();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">31</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">32</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">33</b><span><span class=""> const browser = await puppeteer.launch();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">34</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">35</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">36</b><span><span class=""> await client.send('Network.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">37</b><span><span class=""> await client.send('Network.setCacheDisabled', { cacheDisabled: true });</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">38</b><span><span class=""> await page.screenshot({path: 'google.png'});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">39</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">40</b><span><span class="">})();</span></span></span></code></div><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/bottom_arrow.svg" class="w-16 mx-auto pb-5" alt="Full Screen" width="16" height="16"/></p></div><div class="s__code__block smtablet:hidden tracking-wider flex items-start leading-relaxed hover:underline text-size-12 font-normal text-gray-800"><div class="f_screen w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><a href="https://www.lambdatest.com/automation-testing-advisor/copilotcodeviewer/?snippet=" rel="noopener noreferrer" target="_blank"> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/fullscreen.svg" class="w-16" alt="Full Screen" width="16" height="16"/></a></div></div></div><div class="selenium_code_block border border-lambda-40 rounded-md my-30 relative"><div class="flex smtablet:block flex-wrap justify-between items-center px-20 border-b border-lambda-40"><p class="smtablet:w-full xll:text-size-16 xl:text-size-14 text-size-12 font-medium text-black"/><p class="flex items-center md:justify-end smtablet:w-full smtablet:text-left xll:text-size-16 xl:text-size-14 text-size-12 font-normal text-right break-all copilotsnippet_css"><span class="copilot_border mr-20"/>Using AI Code Generation</p></div><div class="copy_code_snippet"><div class="w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/copy.svg" class="w-20 ml-10" alt="copy" width="18" height="18"/></div></div><p class="bg-black text-white py-15 px-30 rounded-lg inline-block xxl:text-size-20 text-size-18 copy_code_done hidden"/><div class="box_s"><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/top_arrow.svg" class="w-16 mx-auto pt-5" alt="Full Screen" width="16" height="16"/></p><div class="CodeHighlighter"><code class="block"><span class="block code_snippet_line"><b class="code_snippet_line_number">1</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">2</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">3</b><span><span class=""> const browser = await puppeteer.launch({headless: false});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">4</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">5</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">6</b><span><span class=""> await client.send('Page.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">7</b><span><span class=""> await client.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: '/home/username/Downloads'});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">8</b><span><span class=""> await page.screenshot({path: 'google.png'});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">9</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">10</b><span><span class="">})();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">11</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">12</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">13</b><span><span class=""> const browser = await puppeteer.launch({headless: false});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">14</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">15</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">16</b><span><span class=""> await client.send('Page.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">17</b><span><span class=""> await client.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: '/home/username/Downloads'});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">18</b><span><span class=""> await page.screenshot({path: 'google.png'});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">19</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">20</b><span><span class="">})();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">21</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">22</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">23</b><span><span class=""> const browser = await puppeteer.launch({headless: false});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">24</b><span><span class=""> const page = await browser.newPage();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">25</b><span><span class=""> const client = await page.target().</span><mark class="YourHighlightClass ">createCDPSession</mark><span class="">();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">26</b><span><span class=""> await client.send('Page.enable');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">27</b><span><span class=""> await client.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: '/home/username/Downloads'});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">28</b><span><span class=""> await page.screenshot({path: 'google.png'});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">29</b><span><span class=""> await browser.close();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">30</b><span><span class="">})();</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">31</b><span><span class="">const puppeteer = require('puppeteer');</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">32</b><span><span class="">(async () => {</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">33</b><span><span class=""> const browser = await puppeteer.launch({headless: false});</span></span></span><span class="block code_snippet_line"><b class="code_snippet_line_number">34</b><span><span class=""> const page = await browser.newPage();</span></span></span></code></div><p><img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/bottom_arrow.svg" class="w-16 mx-auto pb-5" alt="Full Screen" width="16" height="16"/></p></div><div class="s__code__block smtablet:hidden tracking-wider flex items-start leading-relaxed hover:underline text-size-12 font-normal text-gray-800"><div class="f_screen w-40 h-40 flex items-center rounded-full shadow-lg bg-white cursor-pointer"><a href="https://www.lambdatest.com/automation-testing-advisor/copilotcodeviewer/?snippet=" rel="noopener noreferrer" target="_blank"> <img loading="lazy" src="https://www.lambdatest.com/automation-testing-advisor/resources/images/testing/fullscreen.svg" class="w-16" alt="Full Screen" width="16" height="16"/></a></div></div></div></div> <div class="shadow-sm rounded-2xl border border-lambda-40 p-32 my-50 advisor_hub"><h2>Automation Testing Tutorials</h2> <p>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.</p> <h2>LambdaTest Learning Hubs:</h2> <li><a href="https://www.lambdatest.com/learning-hub/junit-tutorial">JUnit Tutorial</a></li> <li><a href="https://www.lambdatest.com/learning-hub/testng">TestNG Tutorial</a></li> <li><a href="https://www.lambdatest.com/learning-hub/webdriver">Webdriver Tutorial</a></li> <li><a href="https://www.lambdatest.com/learning-hub/webdriverio">WebDriverIO Tutorial</a></li> <li><a href="https://www.lambdatest.com/learning-hub/protractor">Protractor Tutorial</a></li> <li><a href="https://www.lambdatest.com/learning-hub/selenium-4">Selenium 4 Tutorial</a></li> <li><a href="https://www.lambdatest.com/learning-hub/jenkins">Jenkins Tutorial</a></li> <li><a href="https://www.lambdatest.com/learning-hub/nunit-tutorial">NUnit Tutorial</a></li> <li><a href="https://www.lambdatest.com/learning-hub/jest-tutorial">Jest Tutorial</a></li>
推荐文章
另类的砖头
·
7款强大的Javascript网格插件推荐 - CSDN文库
4 周前
追风的水煮鱼
·
wolfcrypt: the wolfSSL Crypto Engine — wolfcrypt 0.1.9 documentation
1 月前
爱喝酒的皮带
·
javascript 监测页面离开事件_js 监听网页离开时间-CSDN博客
1 月前
傻傻的作业本
·
iota币论坛_扬光币圈-虚拟币行情与资讯发布平台
6 月前
慈祥的萝卜
·
vue3 拖动元素到另一个元素中,拖动到删除中 - 掘金
9 月前