{"id":3040,"date":"2025-01-14T14:01:18","date_gmt":"2025-01-14T14:01:18","guid":{"rendered":"https:\/\/rahulshettyacademy.com\/blog\/?p=3040"},"modified":"2025-01-17T10:27:02","modified_gmt":"2025-01-17T10:27:02","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><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<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&nbsp;<\/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<p><span><img decoding=\"async\" alt=\"\" data-id=\"3045\" width=\"907\" data-init-width=\"1164\" height=\"843\" data-init-height=\"1082\" title=\"1\" loading=\"lazy\" src=\"https:\/\/rahulshettyacademy.com\/blog\/wp-content\/uploads\/2025\/01\/1-3.png\" data-width=\"907\" data-height=\"843\" style=\"aspect-ratio: auto 1164 \/ 1082;\"><\/span><\/p>\n<p>&nbsp;To launch the browser, the test needs to be executed in header mode.&nbsp;<\/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<p><span><img decoding=\"async\" alt=\"\" data-id=\"3046\" width=\"836\" data-init-width=\"1164\" height=\"1161\" data-init-height=\"1616\" title=\"2\" loading=\"lazy\" src=\"https:\/\/rahulshettyacademy.com\/blog\/wp-content\/uploads\/2025\/01\/2-3.png\" data-width=\"836\" data-height=\"1161\" style=\"aspect-ratio: auto 1164 \/ 1616;\"><\/span><\/p>\n<p>&nbsp;<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<p><span><img decoding=\"async\" alt=\"\" data-id=\"3047\" width=\"924\" data-init-width=\"1192\" height=\"1136\" data-init-height=\"1466\" title=\"3\" loading=\"lazy\" src=\"https:\/\/rahulshettyacademy.com\/blog\/wp-content\/uploads\/2025\/01\/3-1.png\" data-width=\"924\" data-height=\"1136\" style=\"aspect-ratio: auto 1192 \/ 1466;\"><\/span><\/p>\n<p>&nbsp;<strong>Launch webkit browser using playwright<\/strong><\/p>\n<p>To launch webkit browser, see line#16<\/p>\n<p><span><img decoding=\"async\" alt=\"\" data-id=\"3048\" width=\"900\" data-init-width=\"1208\" height=\"1243\" data-init-height=\"1668\" title=\"4\" loading=\"lazy\" src=\"https:\/\/rahulshettyacademy.com\/blog\/wp-content\/uploads\/2025\/01\/4-3.png\" data-width=\"900\" data-height=\"1243\" style=\"aspect-ratio: auto 1208 \/ 1668;\"><\/span><\/p>\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).&nbsp;<\/p>\n<p>Also, let us uncomment line#19 and comment line#21&nbsp;<\/p>\n<p><span><img decoding=\"async\" alt=\"\" data-id=\"3049\" width=\"912\" data-init-width=\"1208\" height=\"524\" data-init-height=\"694\" title=\"5\" loading=\"lazy\" src=\"https:\/\/rahulshettyacademy.com\/blog\/wp-content\/uploads\/2025\/01\/5-3.png\" data-width=\"912\" data-height=\"524\" style=\"aspect-ratio: auto 1208 \/ 694;\"><\/span><\/p>\n<p>&nbsp;Execute the code, notice that the chrome browser launches<\/p>\n<p><span><img decoding=\"async\" alt=\"\" data-id=\"3050\" width=\"859\" data-init-width=\"1208\" height=\"1168\" data-init-height=\"1642\" title=\"6\" loading=\"lazy\" src=\"https:\/\/rahulshettyacademy.com\/blog\/wp-content\/uploads\/2025\/01\/6-3.png\" data-width=\"859\" data-height=\"1168\" style=\"aspect-ratio: auto 1208 \/ 1642;\"><\/span><\/p>\n<p>&nbsp;Execute the code, notice that the edge browser gets launched&nbsp;<\/p>\n<p><span><img decoding=\"async\" alt=\"\" data-id=\"3051\" width=\"852\" data-init-width=\"1208\" height=\"549\" data-init-height=\"778\" title=\"7\" loading=\"lazy\" src=\"https:\/\/rahulshettyacademy.com\/blog\/wp-content\/uploads\/2025\/01\/7-3.png\" data-width=\"852\" data-height=\"549\" style=\"aspect-ratio: auto 1208 \/ 778;\"><\/span><\/p>\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>\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>\n<p><strong>public<\/strong><strong>class<\/strong> Blog3_launchChromiumFFWebkit {<\/p>\n<p>@Test<\/p>\n<p><strong>public<\/strong><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>\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>\n<p><strong>public<\/strong><strong>class<\/strong> Blog3_launchChromiumFFWebkit {<\/p>\n<p>@Test<\/p>\n<p><strong>public<\/strong><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>\n<p>Thanks!<\/p><\/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":750,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[],"class_list":["post-3040","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","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":8,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3040\/revisions"}],"predecessor-version":[{"id":3691,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3040\/revisions\/3691"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/media\/750"}],"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}]}}