Storing and retrieving a profile

We can also write the profile information of the browser to the JSON file and later instantiate new browsers with the same profile. The FirefoxProfile class provides a method to export the profile information as JSON. The following is its API syntax:

public String toJson()

The output or return type is a String, which contains the JSON information in it.

Now, to create a browser with the same profile, the FirefoxProfile class provides a static method that takes the JSON string as the input. The following is the API syntax:

public static FirefoxProfile fromJson(java.lang.String json) throws java.io.IOException

This is a static method in the FirefoxProfile class that takes the JSON string to create a profile ...

Get Selenium WebDriver 3 Practical Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.