Playwright + Java · Lesson 15 of 38

0/38 done

Module 15: Installation & Setup

15. Maven Configuration & First Playwright Test

15 minlesson

Your task

Implement configureLaunchOptions:

  1. Accept boolean isHeadless and double slowMoMs.
  2. Return new BrowserType.LaunchOptions().setHeadless(isHeadless).setSlowMo(slowMoMs).

Write it in the editor, then press Check answer (Ctrl + Enter).

Maven Dependency Setup (pom.xml)

xml
<dependency>
    <groupId>com.microsoft.playwright</groupId>
    <artifactId>playwright</artifactId>
    <version>1.48.0</version>
</dependency>

Launch Options in Java

java
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions()
    .setHeadless(false)
    .setSlowMo(100);

Browser browser = playwright.chromium().launch(options);

Key Takeaways & Walkthrough Summary

In this lesson, we configure the Maven pom.xml file with the official Playwright dependency, install browser binaries, configure headless vs headed launch options, and execute our first test program. Let's get started!

Part of the Playwright + Java course (Playwright with Java). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.

Common Doubts & Lesson Q&A

How do I download the browser binaries for Playwright Java?

Run 'mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="install"' or let Playwright auto-install on the first run.

Ready? Solve the task in the editor

Use Check answer to mark it complete. Hints are there if you need them.

Java
Skip