TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • TestNG
  • Tools
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Selenium

JSON wire protocol

Introduction

In this tutorial, we will discuss the JSON wire protocol. Selenium Webdriver uses JSON wire protocol to communicate between tests and different browser drivers like Mozilla Firefox GeckoDriver, Microsoft Edge Driver, Safari Driver, Chrome Driver, etc. RemoteWebDriver client and RemoteWebDriver server communicate with JSON wire protocol under the hood.

What is JSON?

JSON (JavaScript Object Notation) is a lightweight data-interchange format. This format is easy for humans to read and write. It is easy for machines to parse and generate. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers. It is a collection of name/value pairs. An ordered list of values.

Example JSON below:

{
“firstname”: “Mark”,
“lastname”: “Twain”,

}

What is the JSON wire protocol?

The JSON wire protocol is a transport mechanism. We can interact with it using a REST API. We can control different browsers/mobile devices and their behavior over a session. JSON is used to represent objects with complex data structures. It is used primarily to transfer data between a server and a client on top of HTTP protocol.

HTTP Header

It is an industry-standard for various REST web services. For example, a client sends a request to a server in JSON format, which the server can parse and responds with the response in the JSON format. A Content-Type http header is used with ‘application/json’ to use the JSON exchange format or payload.

Basic terminology

The client is the machine on which the WebDriver API is being used. The server is the machine running the RemoteWebDriver. This may also refer to a specific browser that implements the wire protocol directly, like Mozilla Firefox GeckoDriver.

Session: The server should maintain one browser per session. We can see that commands sent to a session will be directed to the corresponding browser.

JSON API log on SauceLabs Cloud Test

 

Automated Test Sauce Labs Logs

 

Sample API Call

POST /session

Sample HTTP Request
{
 "desiredCapabilities": {
 "deviceName": "Samsung Galaxy S9 Plus HD GoogleAPI Emulator",
 "platform": "ANDROID",
 "noSign": true,
 "browserName": "chrome",
 "version": "",
 "proxy": {
 "proxyAutoconfigUrl": "http://127.0.0.1:19876/pac.js",
 "proxyType": "PAC"
 },
 "platformVersion": "8.1",
 "platformName": "Android"
 }
}

Response
HTTP Status: 200

Sample HTTP Response
{
 "deviceName": "emulator-5554",
 "takesScreenshot": true,
 "orientation": "PORTRAIT",
 "networkConnectionEnabled": true,
 "deviceUDID": "emulator-5554",
 "newCommandTimeout": 0,
 "deviceManufacturer": "Google",
 "deviceScreenSize": "720x1480",
 "deviceModel": "Android SDK built for x86",
 "webdriver.remote.quietExceptions": false,
 "locationContextEnabled": false,
 "platform": "ANDROID",
 "version": "",
 "maxTypingFrequency": 8,
 "noSign": true,
 "platformName": "Android",
 "warnings": {},
 "javascriptEnabled": true,
 "databaseEnabled": false,
 "noReset": true,
 "desired": {
 "deviceName": "Samsung Galaxy S9 Plus HD GoogleAPI Emulator",
 "orientation": "PORTRAIT",
 "udid": "emulator-5554",
 "platformName": "Android",
 "webdriver.remote.quietExceptions": false,
 "noReset": true,
 "platform": "ANDROID",
 "browserName": "chrome",
 "version": "",
 "maxTypingFrequency": 8,
 "newCommandTimeout": 0,
 "noSign": true,
 "platformVersion": "8.1",
 "eventTimings": true,
 "proxy": {
 "proxyAutoconfigUrl": "http://127.0.0.1:19876/pac.js",
 "proxyType": "PAC"
 }
 },
 "browserName": "chrome",
 "proxy": {
 "proxyAutoconfigUrl": "http://127.0.0.1:19876/pac.js",
 "proxyType": "PAC"
 },
 "platformVersion": "8.1.0",
 "webStorageEnabled": false,
 "eventTimings": true,
 "udid": "emulator-5554"
}

 

Any new client library should provide implementations for the Webdriver JSON API to extend the support.  More details on this, please have a look at

https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol

—

Selenium WebDriver Tutorials on this website can be found at:

https://www.testingdocs.com/selenium-webdriver-tutorial

For more details on the Selenium, visit the official website at:

https://www.selenium.dev/

Related Posts

Windows 10 Settings

Selenium /

Add Microsoft Webdriver on Windows OS

Download Selenium Components

Selenium /

Getting Started with Selenium Webdriver

LambdaTest Testing Cloud SaaS Platform

Selenium /

LambdaTest – Testing Cloud SaaS Platform

Selenium /

Selenium 3.0 and Mozilla GeckoDriver

SauceLabs Website

Selenium /

Run an Example Test on SauceLabs

‹ Network Testing Tools› Timeouts Interface in WebDriver API

Recent Posts

  • Antivirus Products for Windows 11 PC
  • Install CodeBlocks IDE on Windows 11
  • Location Privacy Settings on Windows
  • Windows 11 Virus & Threat Protection
  • Download & Install Python on Windows 11
  • Cumulative Update for Windows 11 Version
  • Test execution speed in Selenium IDE
  • Check Windows 11 Free Upgrade
  • Download IntelliJ IDE on Windows 11
  • New MySQL Connection in Workbench

Back to Top

Automation Tutorials

  • JBehave Tutorial
  • Selenium Tutorial
  • TestNG Tutorial
  • JUnit Tutorial

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version