Oral  Brekke

Oral Brekke


Java Version Of The Playwright Testing and Automation Library

🎭 Playwright for Java

Playwright is a Java library to automate Chromium, Firefox and WebKit with a single API. Playwright is built to enable cross-browser web automation that is ever-green, capable, reliable and fast.

Chromium 102.0.5005.40
WebKit 15.4
Firefox 99.0.1


Playwright requires Java 8 or newer.

Add Maven dependency

Playwright is distributed as a set of Maven modules. The easiest way to use it is to add one dependency to your Maven pom.xml file as described below. If you're not familiar with Maven please refer to its documentation.

To run Playwright simply add following dependency to your Maven project:

<dependency>  <groupId>com.microsoft.playwright</groupId>  <artifactId>playwright</artifactId>  <version>1.17.0</version></dependency>

Is Playwright thread-safe?

No, Playwright is not thread safe, i.e. all its methods as well as methods on all objects created by it (such as BrowserContext, Browser, Page etc.) are expected to be called on the same thread where Playwright object was created or proper synchronization should be implemented to ensure only one thread calls Playwright methods at any given time. Having said that it's okay to create multiple Playwright instances each on its own thread.


You can find Maven project with the examples here.

Page screenshot

This code snippet navigates to whatsmyuseragent.org in Chromium, Firefox and WebKit, and saves 3 screenshots.

import com.microsoft.playwright.*;import java.nio.file.Paths;import java.util.Arrays;import java.util.List;public class PageScreenshot {  public static void main(String[] args) {    try (Playwright playwright = Playwright.create()) {      List<BrowserType> browserTypes = Arrays.asList(        playwright.chromium(),        playwright.webkit(),        playwright.firefox()      );      for (BrowserType browserType : browserTypes) {        try (Browser browser = browserType.launch()) {          BrowserContext context = browser.newContext();          Page page = context.newPage();          page.navigate("http://whatsmyuseragent.org/");          page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("screenshot-" + browserType.name() + ".png")));        }      }    }  }}

Mobile and geolocation

This snippet emulates Mobile Chromium on a device at a given geolocation, navigates to openstreetmap.org, performs action and takes a screenshot.

import com.microsoft.playwright.options.*;import com.microsoft.playwright.*;import java.nio.file.Paths;import static java.util.Arrays.asList;public class MobileAndGeolocation {  public static void main(String[] args) {    try (Playwright playwright = Playwright.create()) {      Browser browser = playwright.chromium().launch();      BrowserContext context = browser.newContext(new Browser.NewContextOptions()        .setUserAgent("Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3765.0 Mobile Safari/537.36")        .setViewportSize(411, 731)        .setDeviceScaleFactor(2.625)        .setIsMobile(true)        .setHasTouch(true)        .setLocale("en-US")        .setGeolocation(41.889938, 12.492507)        .setPermissions(asList("geolocation")));      Page page = context.newPage();      page.navigate("https://www.openstreetmap.org/");      page.click("a[data-original-title=\"Show My Location\"]");      page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("colosseum-pixel2.png")));    }  }}

Evaluate JavaScript in browser

This code snippet navigates to example.com in Firefox, and executes a script in the page context.

import com.microsoft.playwright.*;public class EvaluateInBrowserContext {  public static void main(String[] args) {    try (Playwright playwright = Playwright.create()) {      Browser browser = playwright.firefox().launch();      BrowserContext context = browser.newContext();      Page page = context.newPage();      page.navigate("https://www.example.com/");      Object dimensions = page.evaluate("() => {\n" +        "  return {\n" +        "      width: document.documentElement.clientWidth,\n" +        "      height: document.documentElement.clientHeight,\n" +        "      deviceScaleFactor: window.devicePixelRatio\n" +        "  }\n" +        "}");      System.out.println(dimensions);    }  }}

Intercept network requests

This code snippet sets up request routing for a WebKit page to log all network requests.

import com.microsoft.playwright.*;public class InterceptNetworkRequests {  public static void main(String[] args) {    try (Playwright playwright = Playwright.create()) {      Browser browser = playwright.webkit().launch();      BrowserContext context = browser.newContext();      Page page = context.newPage();      page.route("**", route -> {        System.out.println(route.request().url());        route.resume();      });      page.navigate("http://todomvc.com");    }  }}


Check out our official documentation site.

You can also browse javadoc online.


Follow the instructions to build the project from source and install the driver.

Is Playwright for Java ready?

Yes, Playwright for Java is ready. v1.10.0 is the first stable release. Going forward we will adhere to semantic versioning of the API.

Website | API reference

Author: Microsoft
Source Code: https://github.com/microsoft/playwright-java 
License: Apache-2.0 license

#node #playwright #java #testing 

What is GEEK

Buddha Community

Java Version Of The Playwright Testing and Automation Library
Joseph  Murray

Joseph Murray


7 Test Frameworks To Follow in 2021 for Java/Fullstack Developers

It is time to learn new test frameworks in 2021 to improve your code quality and decrease the time of your testing phase. Let’s explore 6 options for devs.

It is time to learn new test frameworks to improve your code quality and decrease the time of your testing phase. I have selected six testing frameworks that sound promising. Some have existed for quite a long time but I have not heard about them before.

At the end of the article, please tell me what you think about them and what your favorite ones are.

Robot Framework

Robot Framework is a generic open-source automation framework. It can be used for test automation and robotic process automation (RPA).

Robot Framework is open and extensible and can be integrated with virtually any other tool to create powerful and flexible automation solutions. Being open-source also means that Robot Framework is free to use without licensing costs.

The RoboFramework is a framework** to write test cases and automation processes.** It means that it may replace** your classic combo Selenium + Cucumber + Gherkins**. To be more precise, the Cucumber Gherkins custom implementation you wrote will be handled by RoboFramework and Selenium invoked below.

For the Java developers, this framework can be executed with Maven or Gradle (but less mature for the latter solution).

#java #testing #test #java framework #java frameworks #testing and developing #java testing #robot framework #test framework #2021

Aurelie  Block

Aurelie Block


Top 10 Automation Testing Tools: 2020 Edition

The demand for delivering quality software faster — or “Quality at Speed” — requires organizations to search for solutions in Agile, continuous integration (CI), and DevOps methodologies. Test automation is an essential part of these aspects. The latest World Quality Report 2018–2019 suggests that test automation is the biggest bottleneck to deliver “Quality at Speed,” as it is an enabler of successful Agile and DevOps adoption.

Test automation cannot be realized without good tools; as they determine how automation is performed and whether the benefits of automation can be delivered. Test automation tools is a crucial component in the DevOps toolchain. The current test automation trends have increased in applying artificial intelligence and machine learning (AI/ML) to offer advanced capabilities for test optimization, intelligent test generation, execution, and reporting. It will be worthwhile to understand which tools are best poised to take advantage of these trends.****

#automation-testing #automation-testing-tools #testing #testing-tools #selenium #open-source #test-automation #automated-testing

Tyrique  Littel

Tyrique Littel


How to Install OpenJDK 11 on CentOS 8

What is OpenJDK?

OpenJDk or Open Java Development Kit is a free, open-source framework of the Java Platform, Standard Edition (or Java SE). It contains the virtual machine, the Java Class Library, and the Java compiler. The difference between the Oracle OpenJDK and Oracle JDK is that OpenJDK is a source code reference point for the open-source model. Simultaneously, the Oracle JDK is a continuation or advanced model of the OpenJDK, which is not open source and requires a license to use.

In this article, we will be installing OpenJDK on Centos 8.

#tutorials #alternatives #centos #centos 8 #configuration #dnf #frameworks #java #java development kit #java ee #java environment variables #java framework #java jdk #java jre #java platform #java sdk #java se #jdk #jre #open java development kit #open source #openjdk #openjdk 11 #openjdk 8 #openjdk runtime environment

Wiley  Mayer

Wiley Mayer


TestProject Open SDK for Java - Software Testing Material

TestProject is a free automation tool that promises to give painless automation experience. It has the feature of record and plays associated with a developer SDK. It also has the capability to build and utilize addons as per need. It is based on automation tools like Appium and Selenium.

Having said that, TestProject removes the complication of maintaining and downloading multiple browser drivers required for testing an application in various platforms and browsers. This is overcome by having an executable file that can run in the majority of browsers and devices.

#automation #automation testing #codeless test automation #scriptless test automation #test automation #testproject

Mikel  Okuneva

Mikel Okuneva


Where To Learn Test Programming — July 2020 Edition

What do you do when you have lots of free time on your hands? Why not learn test programming strategies and approaches?

When you’re looking for places to learn test programming, Test Automation University has you covered. From API testing through visual validation, you can hone your skills and learn new approaches on TAU.

We introduced five new TAU courses from April through June, and each of them can help you expand your knowledge, learn a new approach, and improve your craft as a test automation engineer. They are:

These courses add to the other three courses we introduced in January through March 2020:

  • IntelliJ for Test Automation Engineers (3 hrs 41 min)
  • Cucumber with JavaScript (1 hr 22 min)
  • Python Programming (2 hrs)

Each of these courses can give you a new set of skills.

Let’s look at each in a little detail.

Mobile Automation With Appium in JavaScript

Orane Findley teaches Mobile Automation with Appium in JavaScript. Orane walks through all the basics of Appium, starting with what it is and where it runs.


“Appium is an open-source tool for automating native, web, and hybrid applications on different platforms.”

In the introduction, Orane describes the course parts:

  • Setup and Dependencies — installing Appium and setting up your first project
  • Working with elements by finding them, sending values, clicking, and submitting
  • Creating sessions, changing screen orientations, and taking screenshots
  • Timing, including TimeOuts and Implicit Waits
  • Collecting attributes and data from an element
  • Selecting and using element states
  • Reviewing everything to make it all make sense

The first chapter, broken into five parts, gets your system ready for the rest of the course. You’ll download and install a Java Developer Kit, a stable version of Node.js, Android Studio and Emulator (for a mobile device emulator), Visual Studio Code for an IDE, Appium Server, and a sample Appium Android Package Kit. If you get into trouble, you can use the Test Automation University Slack channel to get help from Orane. Each subchapter contains the links to get to the proper software. Finally, Orane has you customize your configuration for the course project.

Chapter 2 deals with elements and screen interactions for your app. You can find elements on the page, interact with those elements, and scroll the page to make other elements visible. Orane breaks the chapter into three distinct subchapters so you can become competent with each part of finding, scrolling, and interacting with the app. The quiz comes at the end of the third subchapter.

The remaining chapters each deal with specific bullets listed above: sessions and screen capture, timing, element attributes, and using element states. The final summary chapter ensures you have internalized the key takeaways from the course. Each of these chapters includes its quiz.

When you complete this course successfully, you will have both a certificate of completion and the code infrastructure available on your system to start testing mobile apps using Appium.

Selenium WebDriver With Python

Andrew Knight, who blogs as The Automation Panda, teaches the course on Selenium WebDriver with Python. As Andrew points out, Python has become a popular language for test automation. If you don’t know Python at all, he points you to Jess Ingrassellino’s great course, Python for Test Programming, also on Test Automation University.


In the first chapter, Andrew has you write your first test. Not in Python, but Gherkin. If you have never used Gherkin syntax, it helps you structure your tests in pseudocode that you can translate into any language of your choice. Andrew points out that it’s important to write your test steps before you write test code — and Gherkin makes this process straightforward.

first test case

The second chapter goes through setting up a pytest, the test framework Andrew uses. He assumes you already have Python 3.8 installed. Depending on your machine, you may need to do some work (Macs come with Python 2.7.16 installed, which is old and won’t work. Andrew also goes through the pip package manager to install pipenv. He gives you a GitHub link to his test code for the project. And, finally, he creates a test using the Gherkin codes as comments to show you how a test runs in pytest.

In the third chapter, you set up Selenium Webdriver to work with specific browsers, then create your test fixture in the pytest. Andrew reminds you to download the appropriate browser driver for the browser you want to test — for example, chromedriver to drive Chrome and geckodriver to drive Firefox. Once you use pipenv to install Selenium, you begin your test fixture. One thing to remember is to call an explicit quit for your webdriver after a test.

Chapter 4 goes through page objects, and how you abstract page object details to simplify your test structure. Chapter 5 goes through element locator structures and how to use these in Python. And, in Chapter 6, Andrew goes through some common webdriver calls and how to use them in your tests. These first six chapters cover the basics of testing with Python and Selenium.

Now that you have the basics down, the final three chapters review some advanced ideas: testing with multiple browsers, handling race conditions, and running your tests in parallel. This course gives you specific skills around Python and Selenium on top of what you can get from the Python for Test Programming course.

#tutorial #performance #testing #automation #test automation #automated testing #visual testing #visual testing best practices #testing tutorial