What is the difference between Protocol and Json Wire Protocol

杀马特。学长 韩版系。学妹 提交于 2019-12-04 13:57:39

You are pretty correct both about Protocol and JsonWireProtocol. At this point it is worth to mention that, earlier all implementations of WebDriver that communicated with the browser, or a RemoteWebDriver server shall use a common wire protocol. This wire protocol defines a RESTful web service using JSON over HTTP.

JSON Wire Protocol is an abstract specification of how automation behavior like clicking or typing or whatever you actually want to do with your automation script is mapped to selenium or appium or HTTP requests and response. The protocol will assume that the WebDriver API has been "flattened", but there is an expectation that client implementations will take a more Object-Oriented approach, as demonstrated in the existing Java API. The wire protocol is implemented in request/response pairs of "commands" and "responses".

What is JSON Wire protocol?

JSON (JavaScript Object Notation) is a lightweight format for data exchange between client and server. Applications use JSON objects to send and receive data between each other in the web world. JSON data structure is industry standard and can be used for sending and receiving data as Key & Value pair. Some people say its a very nice alternative for XML. We can save JSON files as .json extension.

How JSON looks like?

A simple json file looks like below and there are many online editors which can be used to edit and verify JSON structure.

{
 "Student":{
   "FirstName":"Pawan",
   "LastName":"Garia",
   "IdNumber":"12345",
   "City" : "New Delhi",
   "EmailID" : "email@gmail.com" }
}

Why JSON Wire Protocol was used in first place?

To implement a client-server architecture which can give us the following benefits.

  • You write test in any programming language.
  • You can perform or run test on cloud services like SauceLabs, BrowserStack or Selenium Grid setup.
  • You are not bound to run test only on the local machine.
  • Different Drivers(FirefoxDriver, ChromeDriver) can be crated for browsers and separate implementation by using the same standards.

So client-server implementation requires a standard set of the specification beforehand so that Server and Client should be in sync with each other in term of what is coming and going on request and response. It’s something like a language of communication with each other. So we need some common specification to solve this kind of requirement and the solution was HTTP.

Why HTTP is the solution?

HTTP is a standard for web and can be a good base for the specification. Every programming language has a good HTTP libraries which can be used for creating client and server for request and response calls.

How JSON Wire protocol worked with HTTP?

HTTP request and response are generally made of GET and POST requests which is out of scope for this discussion.

Current status

From Selenium perspective, JSON Wire Protocol is obsolete now and the WebDriver W3C Living Document is the new implementation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!