Robot Class In Selenium WebDriver

During automation activity Selenium often find difficulty to find an object and perform actions which is related to mouse or keyboard type of activity. It is not easy to perform keyboard or mouse events using selenium commands. There are many specific scenarios where any selenium command is launched but actual event did not fired. This result that execution of test is stopped and it reports some error.

Read More »

JSON.simple example – Write JSON

1. JSON.simple Dependency

JSON.simple is available at Maven central repository, just declares following dependency in your pom.xml file.


2. Write JSON to file

In below example, it write JSON data via JSONObject and JSONArray, and save it into a file named “test.json“.

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;

public class JsonSimpleExample {
public static void main(String[] args) {

JSONObject obj = new JSONObject();
obj.put(“name”, “”);
obj.put(“age”, new Integer(100));

JSONArray list = new JSONArray();
list.add(“msg 1”);
list.add(“msg 2”);
list.add(“msg 3”);

obj.put(“messages”, list);

try {

FileWriter file = new FileWriter(“c:\\test.json”);

} catch (IOException e) {

Output – See content of file named “test.json“.

“messages”:[“msg 1″,”msg 2″,”msg 3”]