Selenium WebDriver With Java 8 – Lambda Expressions and Collections Stream

From Selenium 3.0, minimum Java version is 8. In this article, we illustrate how to use Java 8 features like Lambda expression and Collections Stream to simplify Selenium WebDriver code. Lambda Expression Java lambda expressions are Java’s first step into functional programming. A Java lambda expression is thus a function which can be created without …

How to Encode and Decode JSON Byte Array

The typical way to send binary in JSON is to base64 encode it. Java provides different ways to Base64 encode and decode a byte[]. One of these is DatatypeConverter. Suppose we have a JSON Array as listed below: {“menu”: { “id”: “file”, “value”: “File”, “popup”: { “menuitem”: [ {“value”: “New”, “onclick”: “CreateNewDoc()”}, {“value”: “Open”, “onclick”: “OpenDoc()”}, …

Easiest Way to Read Properties File in Java With ResourceBundle

There are a number of ways to load and read properties file from Java, but the easiest and most straightforward is using the ResourceBundle class. First, you need to create a properties file under resources folder. In a typical Maven project, this looks like the following  In this example, the properties file is called config.properties …

How to Get the Current Working Directory in Java

The current working directory means the root folder of your current Java project. We can get the current working directory in Java using the following system property function: String cwd = System.getProperty(“user.dir”); Example: public class CurrentWorkingDirectory { public static void main (String args[]) { String cwd = System.getProperty(“user.dir”); System.out.println(“Current working directory : ” + cwd); …