{"id":55601,"date":"2022-09-30T15:56:33","date_gmt":"2022-09-30T10:26:33","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=55601"},"modified":"2022-09-30T17:09:25","modified_gmt":"2022-09-30T11:39:25","slug":"understanding-the-new-selenium-grid-4","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/understanding-the-new-selenium-grid-4\/","title":{"rendered":"Understanding the Selenium Grid 4"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">Selenium Grid is an open-source tool to automate web browsers. It allows us to achieve parallel execution of tests on different machines with the benefit of executing the same test suite on all the machines simultaneously. <\/span><span style=\"font-weight: 400;\">The aim is to make testing more efficient and decrease the test execution time. It also aids in lessening network traffic by distributing requests amongst all servers.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Selenium Grid can be primarily used for cross-browser testing, cross-platform testing, and cross-browser compatibility testing. It can be used for functional and non-functional testing. <\/span><span style=\"font-weight: 400;\">It can also be used for performance testing of any web application.<\/span><\/p>\n<p><b>Components of SELENIUM GRID<\/b><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-55600\" src=\"\/blog\/wp-ttn-blog\/uploads\/2022\/09\/components-1.png\" alt=\"\" width=\"1208\" height=\"725\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2022\/09\/components-1.png 1208w, \/blog\/wp-ttn-blog\/uploads\/2022\/09\/components-1-300x180.png 300w, \/blog\/wp-ttn-blog\/uploads\/2022\/09\/components-1-1024x615.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2022\/09\/components-1-768x461.png 768w, \/blog\/wp-ttn-blog\/uploads\/2022\/09\/components-1-624x375.png 624w\" sizes=\"(max-width: 1208px) 100vw, 1208px\" \/><\/p>\n<p><b>1. D<\/b><b>istributor<\/b><\/p>\n<p><span style=\"font-weight: 400;\">It is liable to register and keep track of all Nodes and their capabilities. It is used to query the New Session Queue and then process pending new session requests<\/span><\/p>\n<p><b>2. Session Map<\/b><\/p>\n<p><span style=\"font-weight: 400;\">It is used to maintain a mapping between the session ID and the address of the Node on which the session is running.<\/span><\/p>\n<p><b>3. Router<\/b><\/p>\n<p><span style=\"font-weight: 400;\">It acts as the entry point for the Grid. It is an integral part of the Grid which can<\/span> <span style=\"font-weight: 400;\">be exposed to the wider Web. It can receive all external requests, and send them to the correct component, without overburdening any component which is not needed in the process.<\/span><\/p>\n<p><b>4. Hub<\/b><\/p>\n<p><span style=\"font-weight: 400;\">The hub is the centrist point where tests are loaded into. There is only one hub in a grid. It can be launched in a single machine only.\u00a0<\/span><\/p>\n<p><b>5. Nodes<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Selenium instances are used to execute the tests loaded in the hub. There can be more than one node in a grid. Nodes can launch on several machines with multiple platforms and browsers.<\/span><\/p>\n<p><b>6. Session Queue<\/b><\/p>\n<p><span style=\"font-weight: 400;\">The New Session Queue adheres to the FIFO ordering for all the new sessions which are requested. It consists of configurable parameters in order to set up the request retry interval. and request a timeout.<\/span><\/p>\n<p><b>7. Event Bus<\/b><\/p>\n<p><span style=\"font-weight: 400;\">The Event Bus works as a communication path between the Distributor, Nodes, Session Map, and New Session Queue. The Grid performs most of its internal communication by avoiding expensive HTTP calls and messages.<\/span><\/p>\n<h2><b>Selenium Grid 3 vs Selenium Grid 4<\/b><\/h2>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-55647 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2022\/09\/Screenshot-2022-09-30-153752.png\" alt=\"\" width=\"1198\" height=\"241\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2022\/09\/Screenshot-2022-09-30-153752.png 1198w, \/blog\/wp-ttn-blog\/uploads\/2022\/09\/Screenshot-2022-09-30-153752-300x60.png 300w, \/blog\/wp-ttn-blog\/uploads\/2022\/09\/Screenshot-2022-09-30-153752-1024x206.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2022\/09\/Screenshot-2022-09-30-153752-768x154.png 768w, \/blog\/wp-ttn-blog\/uploads\/2022\/09\/Screenshot-2022-09-30-153752-624x126.png 624w\" sizes=\"(max-width: 1198px) 100vw, 1198px\" \/><\/p>\n<h2><b>Different Grid Types<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Previously in Selenium Grid version 3, only Hub and Node(s) were used. Selenium 4 has some new updated and advanced features including two more types of Grid. Below mentioned are the three grid types supported in Selenium 4:<\/span><\/p>\n<p><b>1. Standalone Mode\u00a0<\/b><\/p>\n<p><span style=\"font-weight: 400;\">In the Standalone mode, the Selenium server executes everything in-process. Standalone is a union of all the components of Selenium Grid. If we want to run Hub and Node on the same machine, we can use this mode. It is invoked by running the below-mentioned command on the terminal -&gt;\u00a0<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">java -jar selenium-server-4.4.0.jar standalone<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">The Grid automatically analyzes the WebDrivers for Chrome and Firefox that are present on the system.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The server is listening on http:\/\/localhost:4444\/ which is the same address used in the configuration of the Remote WebDriver. <\/span><span style=\"font-weight: 400;\">The Chrome WebDriver is only registered once the test code is executed.<\/span><\/p>\n<p><b>2. Hub and Node Grid<\/b><\/p>\n<p><span style=\"font-weight: 400;\">This is the traditional technique to use the Grid for Selenium test automation that consists of two major components \u2013 Hub and Nodes<\/span><\/p>\n<p>Hub is the amalgamation of the following components:<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"font-weight: 400;\">Router<\/li>\n<li style=\"font-weight: 400;\">Distributor<\/li>\n<li>Event Bus<\/li>\n<li>New Session Queue<\/li>\n<li>Session Map\n<p><b><\/b><\/li>\n<\/ul>\n<\/li>\n<li><span style=\"font-weight: 400;\">\u00a0Starting Hub in the machine using:<\/span><\/li>\n<\/ul>\n<pre><span style=\"font-weight: 400;\">java -jar selenium-server-4.0.0.jar hub <\/span><\/pre>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">A node having the same machine<br \/>\n<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">java -jar selenium-server-4.4.0.jar node<\/span><\/pre>\n<\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">A node having a different machine<br \/>\n<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">java -jar selenium-server-4.4.0.jar node --detect-drivers <\/span><b>true<\/b><span style=\"font-weight: 400;\"> --publish-events tcp:\/\/{hubIP}:4442 --subscribe-events tcp:\/\/{hubIP}:4443<\/span><\/pre>\n<\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">hubIP &#8211; Displayed in the cmd logs on registering the hub<\/span><\/li>\n<\/ul>\n<p><b>3. Fully Distributed\u00a0<\/b><\/p>\n<p><span style=\"font-weight: 400;\">It can perform in a fully distributed manner, with each piece executing its procedure. In this approach, we have to kickstart all the components individually like Router, Distributor, and more. It is used when we have a larger size Grid to be set up.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><strong>\u00a0Session Map<\/strong>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Maps the Session Ids for the executing node sessions<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Kickstart the Session Map with the help of the below-mentioned command:<br \/>\n<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre><span style=\"font-weight: 400;\">java -jar selenium-server-4.4.0.jar sessions<\/span><\/pre>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">It maps the Session IDs to the node the session is presently running on<\/span><\/span>&nbsp;<\/li>\n<\/ul>\n<\/li>\n<li style=\"font-weight: 400;\"><strong>Event Bus<\/strong>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">It will be used to communicate between different components of the Grid<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Start the Events Bus using the below-mentioned command:<br \/>\n<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">java -jar selenium-server-4.4.0.jar event-bus<\/span><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li style=\"font-weight: 400;\"><strong>Session Queue<\/strong>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Appends the new session requests to a queue<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">This queue will be refined by the distributor later<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Start the Session Queue using the below-mentioned command:<br \/>\n<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">java -jar selenium-server-4.4.0.jar session queue\r\n<\/span><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li style=\"font-weight: 400;\"><strong>Distributor<\/strong>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Nodes inscribe to this Distributor<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">The distributor verifies the Session Queue and then assigns the new sessions to the inscribed node which is accessible to run the sessions<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Start the Distributor using the below-mentioned command:<br \/>\n<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">java -jar selenium-server-4.4.0.jar distributor --sessions http:\/\/192.168.0.112:5556 --sessionqueue http:\/\/192.168.0.112:5559 --bind-bus false\r\n<\/span><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li style=\"font-weight: 400;\"><strong>Router<\/strong>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Navigates the requests to accurate components<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">The entry point of Grid<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Start the Router using the below-mentioned command:<br \/>\n<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">java -jar selenium-server-4.4.0.jar router --sessions http:\/\/192.168.0.112:5556 --distributor http:\/\/192.168.0.112:5553 --sessionqueue http:\/\/192.168.0.112:5559\r\n<\/span><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li style=\"font-weight: 400;\"><strong>Node<\/strong>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Start node in the same machine:<br \/>\n<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">java -jar selenium-server-4.4.0.jar node<\/span><\/pre>\n<\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Start node in a different machine:<br \/>\n<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">java -jar selenium-server-4.4.0.jar node --detect-drivers true --publish-events tcp:\/\/192.168.0.112:4442 --subscribe-events tcp:\/\/192.168.0.112:4443<\/span><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2><b><br \/>\nAdvantages of Selenium Grid<\/b><\/h2>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Open Browser: Selenium is an open source and easily accessible automation framework having no upfront costs. So, users can save lots of money here and utilize them for other good reasons.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Support Multiple Browsers: Firefox, Chrome, IE, etc.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Support Multiple Architecture and OS: Windows, Linux, UNIX, Mac OS, etc.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Escalates Test Execution Time: It boosts up the completion time of the test suite as it can execute multiple tests in parallel. For instance, if we have 5 nodes and we want to run a test suite of 60 tests then it will take 6 times less time than a single machine that runs the same test suite without Selenium Grid. When a node is idle, it picks up the test case waiting in the execution queue on its own.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Execution of Cloud Based: Reliability, Availability, Software Maintenance Cost, and Save Hardware.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Framework and Language Support: It holds up all crucial languages like Java, C#, Python, JavaScript, Perl, Ruby, and programming languages for software test automation.<\/span><\/li>\n<\/ol>\n<h2><b><br \/>\nDisadvantages of Selenium Grid<\/b><\/h2>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Cost: Additional cost for the project as it needs extra machines as Nodes.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Poor Scalability: It has comparatively poor scalability as compared to many present-day applications. It is inadequate to increase or decrease demand.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Reconfiguration: It is static. Each server is customized beforehand with a subset of the needed browser instances available. If you want to differ this, you have to reconfigure it.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Need skilled engineers: Selenium Grid requires skilled engineers to create and maintain things and IT approval.\u00a0<\/span><\/li>\n<\/ol>\n<h2><b><br \/>\nSummary<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">At last, we can say that It will increase the marketing strategy for the big growing companies in the coming future. It is having wide scope in regards to growing Industry standards. It assists with the deployment of non-defective code. A Grid contains a single Hub and one or more Nodes. Both can be used with the help of a selenium-server.jar executable. The Hub receives a test that needs to be run along with detailed information on which browser(Firefox, chrome) and platform (i.e. Windows, Linux\/Unix, etc) where the test should be executed. Since the Hub is aware of each registered Node and its configurations, it picks up any available Node which contains a\u00a0 browser-platform combination that is already requested.<\/span><\/p>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>Selenium Grid is an open-source tool to automate web browsers. It allows us to achieve parallel execution of tests on different machines with the benefit of executing the same test suite on all the machines simultaneously. The aim is to make testing more efficient and decrease the test execution time. It also aids in lessening [&hellip;]<\/p>\n","protected":false},"author":1408,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":37},"categories":[1816],"tags":[14,25,2857],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/55601"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1408"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=55601"}],"version-history":[{"count":4,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/55601\/revisions"}],"predecessor-version":[{"id":55650,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/55601\/revisions\/55650"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=55601"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=55601"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=55601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}