{"id":3040,"date":"2025-01-14T14:01:18","date_gmt":"2025-01-14T14:01:18","guid":{"rendered":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/2025\/01\/14\/launch-chromium-mozilla-webkit-chrome-edge-browsers-using-playwright-java\/"},"modified":"2025-01-14T14:01:18","modified_gmt":"2025-01-14T14:01:18","slug":"launch-chromium-mozilla-webkit-chrome-edge-browsers-using-playwright-java","status":"publish","type":"post","link":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/2025\/01\/14\/launch-chromium-mozilla-webkit-chrome-edge-browsers-using-playwright-java\/","title":{"rendered":"Launch Chromium, Mozilla, Webkit, Chrome, Edge browsers using Playwright-Java"},"content":{"rendered":"<p><html><body><\/p>\n<section class=\"tcb-post-content tcb-shortcode thrv_wrapper\" data-css=\"tve-u-16ec5d248bb\">\n<div class=\"tve_flt tcb-style-wrap\" id=\"tve_flt\">\n<div class=\"tve_shortcode_editor tar-main-content\" data-post-id=\"3040\" id=\"tve_editor\">\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><em>In this blog, you will gain knowledge on how to launch various browsers such as Chromium, Mozilla Firefox, Webkit, Chrome, and Microsoft Edge using Playwright-Java.<\/em><\/p>\n<div class=\"code-block code-block-2\" style=\"margin: 8px auto; text-align: center; display: block; clear: both;\">\n<p><!-- horizontal responsive 2 --><br \/>\n<ins class=\"adsbygoogle\" data-ad-client=\"ca-pub-3231318496783163\" data-ad-format=\"auto\" data-ad-slot=\"2788468763\" data-full-width-responsive=\"true\" style=\"display:block\"><\/ins>\n<\/div>\n<p><strong>Topics that we will cover:<\/strong><\/p>\n<ul>\n<li>Launch chromium browser (in header mode) using playwright<\/li>\n<li>Launch firefox browser using playwright<\/li>\n<li>Launch webkit browser using playwright<\/li>\n<li>Launch chrome browser using playwright<\/li>\n<li>Launch Microsoft Edge browser using playwright<\/li>\n<li>Source code (chromium, firefox, webkit)<\/li>\n<li>Source code (chrome, edge)<\/li>\n<\/ul>\n<p><strong>Launch chromium browser (in header mode) using playwright\u00a0<\/strong><\/p>\n<p>By default, the playwright test runs in headless mode. In our previous blog, we executed a playwright test and the snapshot of the results is provided below. It is worth mentioning that the chromium browser was NOT launched during the execution of the test<\/p>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-194652061c1\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-3045 tcb-moved-image\" data-css=\"tve-u-1946520708b\" data-height=\"843\" data-id=\"3045\" data-init-height=\"1082\" data-init-width=\"1164\" data-width=\"907\" decoding=\"async\" height=\"843\" loading=\"lazy\" src=\"\/blog\/wp-content\/uploads\/2025\/01\/1-3.png\" style=\"aspect-ratio: auto 1164 \/ 1082;\" title=\"1\" width=\"907\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>\u00a0To launch the browser, the test needs to be executed in header mode.\u00a0<\/p>\n<p>To activate the header mode, simply include the highlighted argument in the launch() method, as depicted below:<\/p>\n<p><em>launch(<\/em><em>new BrowserType.LaunchOptions().setHeadless(false)<\/em><em>)<\/em><\/p>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-19465218c83\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-3046\" data-css=\"tve-u-1946521a5aa\" data-height=\"1161\" data-id=\"3046\" data-init-height=\"1616\" data-init-width=\"1164\" data-width=\"836\" decoding=\"async\" height=\"1161\" loading=\"lazy\" src=\"\/blog\/wp-content\/uploads\/2025\/01\/2-3.png\" style=\"aspect-ratio: auto 1164 \/ 1616;\" title=\"2\" width=\"836\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>\u00a0<strong>Launch firefox browser using playwright<\/strong><\/p>\n<p>In order to launch firefox browser, simply comment line#14 and add line#15<\/p>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-194652299fa\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-3047 tcb-moved-image\" data-css=\"tve-u-19465229e95\" data-height=\"1136\" data-id=\"3047\" data-init-height=\"1466\" data-init-width=\"1192\" data-width=\"924\" decoding=\"async\" height=\"1136\" loading=\"lazy\" src=\"\/blog\/wp-content\/uploads\/2025\/01\/3-1.png\" style=\"aspect-ratio: auto 1192 \/ 1466;\" title=\"3\" width=\"924\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>\u00a0<strong>Launch webkit browser using playwright<\/strong><\/p>\n<p>To launch webkit browser, see line#16<\/p>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-194652373c6\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-3048\" data-css=\"tve-u-19465238bfe\" data-height=\"1243\" data-id=\"3048\" data-init-height=\"1668\" data-init-width=\"1208\" data-width=\"900\" decoding=\"async\" height=\"1243\" loading=\"lazy\" src=\"\/blog\/wp-content\/uploads\/2025\/01\/4-3.png\" style=\"aspect-ratio: auto 1208 \/ 1668;\" title=\"4\" width=\"900\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p><strong>Launch chrome browser using playwright<\/strong><\/p>\n<p>In order to start the Chrome browser, all we need to do is instantiate an object of the &#8216;<em>LaunchOptions<\/em>&#8216; class, specify the channel as &#8216;chrome&#8217;, and ensure that the headless mode is set to false (see lines#15-17).\u00a0<\/p>\n<p>Also, let us uncomment line#19 and comment line#21\u00a0<\/p>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-19465244a37\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-3049\" data-css=\"tve-u-19465245c50\" data-height=\"524\" data-id=\"3049\" data-init-height=\"694\" data-init-width=\"1208\" data-width=\"912\" decoding=\"async\" height=\"524\" loading=\"lazy\" src=\"\/blog\/wp-content\/uploads\/2025\/01\/5-3.png\" style=\"aspect-ratio: auto 1208 \/ 694;\" title=\"5\" width=\"912\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>\u00a0Execute the code, notice that the chrome browser launches<\/p>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-19465254054\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-3050\" data-css=\"tve-u-1946525594a\" data-height=\"1168\" data-id=\"3050\" data-init-height=\"1642\" data-init-width=\"1208\" data-width=\"859\" decoding=\"async\" height=\"1168\" loading=\"lazy\" src=\"\/blog\/wp-content\/uploads\/2025\/01\/6-3.png\" style=\"aspect-ratio: auto 1208 \/ 1642;\" title=\"6\" width=\"859\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>\u00a0Execute the code, notice that the edge browser gets launched\u00a0<\/p>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-19465260852\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-3051\" data-css=\"tve-u-19465261b77\" data-height=\"549\" data-id=\"3051\" data-init-height=\"778\" data-init-width=\"1208\" data-width=\"852\" decoding=\"async\" height=\"549\" loading=\"lazy\" src=\"\/blog\/wp-content\/uploads\/2025\/01\/7-3.png\" style=\"aspect-ratio: auto 1208 \/ 778;\" title=\"7\" width=\"852\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<p>So this is how we can launch various browser types.<\/p>\n<p><strong>Source code (chromium, firefox, webkit)<\/strong><\/p>\n<p><strong>package<\/strong> com.rsa.playwrightjava;<\/p>\n<p><\/p>\n<p><strong>import<\/strong> org.junit.jupiter.api.Test;<\/p>\n<p><strong>import<\/strong> com.microsoft.playwright.Browser;<\/p>\n<p><strong>import<\/strong> com.microsoft.playwright.BrowserType;<\/p>\n<p><strong>import<\/strong> com.microsoft.playwright.Page;<\/p>\n<p><strong>import<\/strong> com.microsoft.playwright.Playwright;<\/p>\n<p><\/p>\n<p><strong>public<\/strong><br \/>\n<strong>class<\/strong> Blog3_launchChromiumFFWebkit {<\/p>\n<p>@Test<\/p>\n<p><strong>public<\/strong><br \/>\n<strong>void<\/strong> PlaywrightJTest() {<\/p>\n<p>Playwright pt = Playwright.<em>create<\/em>();<\/p>\n<p>\/\/BrowserType btype = pt.chromium();<\/p>\n<p>\/\/BrowserType btype = pt.firefox();<\/p>\n<p>BrowserType btype = pt.webkit();<\/p>\n<p>Browser b = btype.launch((<strong>new<\/strong> BrowserType.LaunchOptions().setHeadless(<strong>false<\/strong>)));<\/p>\n<p>\/\/Page pg = pt.chromium().launch().newPage();<\/p>\n<p>Page pg = b.newPage();<\/p>\n<p>pg.navigate(&#8220;https:\/\/www.google.com\/&#8221;);<\/p>\n<p>System.<strong><em>out<\/em><\/strong>.println(pg.title());<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p><strong>Source code (chrome, edge)<\/strong><\/p>\n<p><strong>package<\/strong> com.rsa.playwrightjava;<\/p>\n<p><\/p>\n<p><strong>import<\/strong> org.junit.jupiter.api.Test;<\/p>\n<p><strong>import<\/strong> com.microsoft.playwright.Browser;<\/p>\n<p><strong>import<\/strong> com.microsoft.playwright.BrowserType;<\/p>\n<p><strong>import<\/strong> com.microsoft.playwright.BrowserType.LaunchOptions;<\/p>\n<p><strong>import<\/strong> com.microsoft.playwright.Page;<\/p>\n<p><strong>import<\/strong> com.microsoft.playwright.Playwright;<\/p>\n<p><\/p>\n<p><strong>public<\/strong><br \/>\n<strong>class<\/strong> Blog3_launchChromiumFFWebkit {<\/p>\n<p>@Test<\/p>\n<p><strong>public<\/strong><br \/>\n<strong>void<\/strong> PlaywrightJTest() {<\/p>\n<p>Playwright pt = Playwright.<em>create<\/em>();<\/p>\n<p>LaunchOptions lo = <strong>new<\/strong> LaunchOptions();<\/p>\n<p>\/\/lo.setChannel(&#8220;chrome&#8221;);<\/p>\n<p>lo.setChannel(&#8220;msedge&#8221;);<\/p>\n<p>lo.setHeadless(<strong>false<\/strong>);<\/p>\n<p>BrowserType btype = pt.chromium();<\/p>\n<p>\/\/BrowserType btype = pt.firefox();<\/p>\n<p>\/\/BrowserType btype = pt.webkit();<\/p>\n<p>Browser b = btype.launch((<strong>new<\/strong> BrowserType.LaunchOptions().setHeadless(<strong>false<\/strong>)));<\/p>\n<p>\/\/Page pg = pt.chromium().launch().newPage();<\/p>\n<p>Page pg = b.newPage();<\/p>\n<p>pg.navigate(&#8220;https:\/\/www.google.com\/&#8221;);<\/p>\n<p>System.<strong><em>out<\/em><\/strong>.println(pg.title());<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p><\/p>\n<p>Thanks!<\/p>\n<p><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"tcb_flag\" style=\"display: none\"><\/div>\n<\/section>\n<p><\/body><\/html><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog, you will gain knowledge on how to launch various browsers such as Chromium, Mozilla Firefox, Webkit, Chrome, and Microsoft Edge using Playwright-Java. Topics that we will cover: Launch chromium browser (in header mode) using playwright Launch firefox browser using playwright Launch webkit browser using playwright Launch chrome browser using playwright Launch Microsoft [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,9],"tags":[],"class_list":["post-3040","post","type-post","status-publish","format-standard","hentry","category-java","category-playwright","post-wrapper","thrv_wrapper"],"_links":{"self":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3040","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=3040"}],"version-history":[{"count":0,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3040\/revisions"}],"wp:attachment":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=3040"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=3040"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=3040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}