Working with JSON Wire Protocol: Selenium

INTRODUCTION

Selenium is a browser Automation tool which uses JSON Wire Protocol
All implementations of WebDriver that communicate 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.
The wire protocol is implemented in request/response pairs of "commands" and "responses".

Step1 - Download Selenium Stand Alone Server.
Step2 - Download any Driver.exe. ie geckodriver for firefox or chromedriver for ch
Step3 - Keep both Files in same folder(JSON)-    D:\selenium-server\JSON

Open cmd and run the following commands-
cd D:\selenium-server\JSON

and give this command to start selenium server -             java -jar selenium-server-standalone-3.14.0.jar

(Allow the access, and you will see - Launching a standalone Selenium Server on port 4444
Selenium Server is up and running on your port 4444)
 in your browser  -    http://localhost:4444     -        and then Click on console.

Click on Create Session.
Step-1 Choose the Browser(eg - Firefox/chrome)
Step-2 Session ID will be seen on console (eg 4fdeebb2-4e1a-4f00-9427-e893fac614d3)
(A new automated Firefox window will open)
Step-3 Click on  Capabilities to see JSON payload.
Click on take screenshot. (on selenium standalone server it will appear blank but on cmd you can see values being generated for that session)
Step-4 Download and run POSTMAN(if browser is chrome).
Step-5 Copy the url http://localhost:4444/wd/hub from standalone console.
Step-6 Paste it in POSTMAN and then type command -
a) GET /sessions and click on send button.
b) GET /session/:sessionid -> :sessionid means you have to paste a sessionid here
c) POST  /session/:sessionId/url -> in this you have to pass the arguments so, 
Click on Body -> Select raw data -> Select JSON from Dropdown
Type: 
{
"url": "https://www.google.com/"
}
d) POST /session/:sessionId/refresh -> Refresh the browser page
Status 200(positive) OK in middle right means our command has been executed successfully.
e) GET /session/:sessionId/screenshot
 

TO Shutdown the server

 http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer

 

 

**************************************************************************************

QACult Best Software Testing Courses in Chandigarh tricity.- We love to enhance your knowledge.

QACult is the premier institute catering to the requirements of experienced and fresh pass-out that gives leaders like you a new way to experience Quality engineering—while you work and giving you the flexibility to both advance your career.
Our faculty have 12+ years of industrial experience and have developed many automation testing frameworks in java using TestNG or BDD (cucumber) methodology. We expertise in developing automation testing frameworks in java, python, javascript, php, ruby(WATIR-webdriver & Capybara) and Appium.
please subscribe our channel for more such updates:  

https://www.youtube.com/channel/UC0xat537YITJbN_9GSMUALA
And visit our website: www.qacult.com for various blogs and Upcoming Events.