{"id":3791,"date":"2020-11-13T10:04:40","date_gmt":"2020-11-13T09:04:40","guid":{"rendered":"https:\/\/www.brainbox.consulting\/?p=3791"},"modified":"2020-11-13T10:04:40","modified_gmt":"2020-11-13T09:04:40","slug":"selenium-grid","status":"publish","type":"post","link":"https:\/\/brainbox.consulting\/talent\/selenium-grid\/","title":{"rendered":"Selenium Grid"},"content":{"rendered":"<h2><strong>Introduction<\/strong><\/h2>\n<p>Selenium Grid is a feature in selenium that allows you run test cases in different machines across different platforms. It also makes it easy to run tests in parallel on multiple machines. This is done by routing commands to remote web browser instances, where one server acts as the hub. This hub routes test commands that are in JSON format to multiple registered Grid nodes.<\/p>\n<p>Read on further to know more about selenium grid in this article.<\/p>\n<h2><strong>What is Selenium?<\/strong><\/h2>\n<p>Before we dig deeper into the benefits of using Selenium Grid for Selenium test automation, we must have a look at the basics of Selenium. Selenium is an open-source test framework that is used to automate the actions of the product under test. To put it plainly, Selenium automates a web browser to behave like a user while allowing you to write test scripts in different programming languages including Java, Ruby, PHP, Python, C#, NodeJS, etc. Selenium-based tests are ideal for testing different types and versions of web browsers.<\/p>\n<p>There are 4 components of the Selenium project.<\/p>\n<ol>\n<li><span style=\"color: #000000;\">Selenium RC<\/span><\/li>\n<li><span style=\"color: #000000;\">Selenium IDE (Integrated Development Environment)<\/span><\/li>\n<li><span style=\"color: #000000;\">Selenium Grid<\/span><\/li>\n<li><span style=\"color: #000000;\">Selenium WebDriver<\/span><\/li>\n<\/ol>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-3793 aligncenter\" src=\"https:\/\/www.brainbox.consulting\/talent\/wp-content\/uploads\/2020\/11\/selenium1-300x99.png\" alt=\"\" width=\"604\" height=\"200\" srcset=\"https:\/\/brainbox.consulting\/talent\/wp-content\/uploads\/2020\/11\/selenium1-300x99.png 300w, https:\/\/brainbox.consulting\/talent\/wp-content\/uploads\/2020\/11\/selenium1-1024x340.png 1024w, https:\/\/brainbox.consulting\/talent\/wp-content\/uploads\/2020\/11\/selenium1-768x255.png 768w, https:\/\/brainbox.consulting\/talent\/wp-content\/uploads\/2020\/11\/selenium1.png 1137w\" sizes=\"(max-width: 604px) 100vw, 604px\" \/><\/p>\n<p>Selenium WebDriver is the core component of the Selenium framework as it enables the interfacing of the test code with the elements of the web page under test. It communicates directly with a web browser and has a browser-specific application. On the other hand, Selenium IDE or Selenium Integrated Development Environment is a plugin that allows you to record test scripts and playback the existing ones. \u00a0Selenium RC is a testing framework that enables a QA or a developer to write test cases in any programming language to automate UI tests for web applications against any HTTP website.<\/p>\n<h2>What is Selenium Grid?<\/h2>\n<p>Selenium Grid is a testing tool (which is a part of the Selenium Suite) that is based on the \u2018client-server\u2019 architecture. In Selenium Grid terminology, Client machine is termed as \u2018Hub\u2019 and server(s) are termed as \u2018Nodes\u2019.<\/p>\n<p>Selenium Grid setup allows you to execute cross browser testing through a variety of different machines across different browsers (as well as different versions of browsers) &amp; different operating systems. Hence, it brings the require amount of \u2018parallelism\u2019 &amp; \u2018distribution\u2019 to your test execution environment.<\/p>\n<p>A Selenium Grid setup can have only one Hub and \u2018n\u2019 number of nodes. The primary job of the \u2018hub machine\u2019 is to distribute the test case supplied to the \u2018node machine\u2019 which matches the capabilities\/requirements required for executing the test case for performing\u00a0cross browser testing.<\/p>\n<h3><strong>Primary Components <\/strong><strong>o<\/strong><strong>f the Selenium Grid Setup<\/strong><\/h3>\n<p>There are mainly 2 components in Selenium Grid setup,<\/p>\n<ol>\n<li><span style=\"color: #000000;\"><strong>Hub: <\/strong>Hub acts as a master in Selenium Grid. There will be a single hub in the grid which will know the configuration of each registered node. When specific test requirements are given to the hub, then hub searches for the node which matches the test requirements. If hub founds a node which matches the test requirements, then test will be executed on that node machine. If node with required specifications is not found, then hub returns an error.<\/span><\/li>\n<li><span style=\"color: #000000;\"><strong>Node: <\/strong>Node acts as slave in Selenium Grid. There can be one or more nodes present in the Grid. Node machines can have different configuration like OS, different versions of browsers etc.\u2026 It is not mandatory for a node to have same configuration as that of hub machine. Nodes are dependent on Hub.<\/span><\/li>\n<\/ol>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-3796 aligncenter\" src=\"https:\/\/www.brainbox.consulting\/talent\/wp-content\/uploads\/2020\/11\/grid-300x287.png\" alt=\"\" width=\"440\" height=\"421\" srcset=\"https:\/\/brainbox.consulting\/talent\/wp-content\/uploads\/2020\/11\/grid-300x287.png 300w, https:\/\/brainbox.consulting\/talent\/wp-content\/uploads\/2020\/11\/grid.png 548w\" sizes=\"(max-width: 440px) 100vw, 440px\" \/><\/p>\n<h2><strong>\u00a0<\/strong><strong>When to u<\/strong><strong>se Selenium Grid?<\/strong><\/h2>\n<p><span style=\"color: #000000;\">Selenium Grid can be used in the following circumstances:<\/span><\/p>\n<ol>\n<li><span style=\"color: #000000;\">To run tests on multiple browsers and their versions, different devices, and operating systems<\/span><\/li>\n<li><span style=\"color: #000000;\">To reduce the time that a test suite takes to complete a test<\/span><\/li>\n<\/ol>\n<p><span style=\"color: #000000;\">Selenium Grid improves the turnaround time of tests especially when the test suite is large. It offers flexibility and widens the coverage of tests.<\/span><\/p>\n<h2><strong>\u00a0<\/strong><strong>How Selenium Grid works<\/strong><\/h2>\n<p>A Selenium Grid setup can have only one Hub and \u2018n\u2019 number of nodes. The primary job of the \u2018hub machine\u2019 is to distribute the test case supplied to the \u2018node machine\u2019 which matches the capabilities\/requirements required for executing the test case for performing cross browser testing.<\/p>\n<p>For example, you can set up a Selenium Grid with a hub and two nodes, where the node configuration is as below:<\/p>\n<p>Node 1 \u2013 Windows 10, Chrome<\/p>\n<p>Node 2 \u2013 Windows 10, Firefox<\/p>\n<p>If there is a test case that has the Desired Capabilities requirement as Windows 10 + Chrome, the hub first receives the request for this requirement. By looking at the requirement, it diverts the execution request to Node 1.<\/p>\n<p>In case you want to use the Selenium WebDriver to execute tests on a separate machine, you must use Remote WebDriver interface. Since the tests (in normal scenarios) must be executed on a different machine, RemoteWebDriver is based on the traditional \u2018Client-Server\u2019 model.<\/p>\n<h2><strong>Use case<\/strong><\/h2>\n<p>At Brainbox, we have developed a Test Automation Framework for end to end application testing of web and mobile android platforms. You can find the details about the framework here <a href=\"https:\/\/www.brainbox.consulting\/talent\/blogs-news\/software-testing-blog\/brainbox-test-automation-framework\/\">https:\/\/www.brainbox.consulting\/talent\/blogs-news\/software-testing-blog\/brainbox-test-automation-framework\/<\/a>.<\/p>\n<h3><strong>Brainbox Test Automation Framework Architecture<\/strong><\/h3>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-3798 aligncenter\" src=\"https:\/\/www.brainbox.consulting\/talent\/wp-content\/uploads\/2020\/11\/architecture-300x169.png\" alt=\"\" width=\"794\" height=\"447\" srcset=\"https:\/\/brainbox.consulting\/talent\/wp-content\/uploads\/2020\/11\/architecture-300x169.png 300w, https:\/\/brainbox.consulting\/talent\/wp-content\/uploads\/2020\/11\/architecture-1024x576.png 1024w, https:\/\/brainbox.consulting\/talent\/wp-content\/uploads\/2020\/11\/architecture-768x432.png 768w, https:\/\/brainbox.consulting\/talent\/wp-content\/uploads\/2020\/11\/architecture-1536x864.png 1536w, https:\/\/brainbox.consulting\/talent\/wp-content\/uploads\/2020\/11\/architecture.png 1920w\" sizes=\"(max-width: 794px) 100vw, 794px\" \/><\/p>\n<p>This\u00a0framework uses\u00a0a\u00a0keyword driven approach (similar to BDD) where the test cases\u00a0and\u00a0test steps\u00a0can be defined via simple English specified in an excel document. When there are any issues in test cases or in test steps, error recovery block will detect the defects. The next layer, Application and Business specific layer consists of business specific modules such as login function of a website. The subsequent layer contains configuration files, verifications, and UI objects. When a test fails, the Test exception handling module will handle the failure. The same layer also contains test logging and reporting session. Test automation-Tool &amp; Runner layer contains tools like Selenium, Python and Appium Studio for test automation. \u00a0Automation test agent\/Drivers layer connects Selenium with browsers and Appium with the device. The bottom layer (application under test) gives users flexibility to choose the test cases and the necessary steps. This framework also supports\u00a0automation of\u00a0hybrid test\u00a0scenarios consisting test steps and verification across applications on\u00a0Web and Mobile\u00a0platform.\u00a0It supports\u00a0testing of web applications on\u00a0different browsers like Google Chrome, Firefox, Microsoft Edge, and Internet Explorer.\u00a0 Selenium grid is used in this framework to run multiple tests parallelly. The hub and multiple nodes are created for different browsers. The primary job of the hub machine is to distribute the test case supplied to the node machine. When a user performs a test, it goes through the hub and depending on the browser the tests will be executed.<\/p>\n<h2><strong>Advantages <\/strong><strong>o<\/strong><strong>f using Selenium Grid <\/strong><strong>f<\/strong><strong>or Automated Browser Testing<\/strong><\/h2>\n<ol>\n<li><span style=\"color: #000000;\">Extensive language support<\/span><\/li>\n<li><span style=\"color: #000000;\">Dedicated framework support<\/span><\/li>\n<li><span style=\"color: #000000;\">Multi-browser support<\/span><\/li>\n<li><span style=\"color: #000000;\">Multi- operating system support<\/span><\/li>\n<li><span style=\"color: #000000;\">Free and open source<\/span><\/li>\n<li><span style=\"color: #000000;\">Parallel test execution (local and cloud based)<\/span><\/li>\n<li><span style=\"color: #000000;\">Powerful reporting for test progress tracking<\/span><\/li>\n<li><span style=\"color: #000000;\">Integration with CI\/CD pipeline<\/span><\/li>\n<li><span style=\"color: #000000;\">Android and iOS mobile apps testing<\/span><\/li>\n<li><span style=\"color: #000000;\">Code reusability for improved maintenance<\/span><\/li>\n<li><span style=\"color: #000000;\">Vibrant developer and support community<\/span><\/li>\n<\/ol>\n<h2><strong>Summary<\/strong><\/h2>\n<p>Selenium Grid offers the flexibility of running test cases across multiple browsers, browser versions and machines. Testers can ensure cross platform compatibility of tests by using Selenium Grid.<\/p>\n<p><span style=\"color: #000000;\">Contact us at <a style=\"color: #000000;\" href=\"mailto:sales@brainbox.consulting\">sales@brainbox.consulting<\/a> for more information and we would be happy to assist you with testing related services.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Selenium Grid is a feature in selenium that allows you run test cases in different machines across different platforms&#8230;.<\/p>\n","protected":false},"author":7,"featured_media":2472,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_mi_skip_tracking":false},"categories":[23],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/brainbox.consulting\/talent\/wp-json\/wp\/v2\/posts\/3791"}],"collection":[{"href":"https:\/\/brainbox.consulting\/talent\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/brainbox.consulting\/talent\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/brainbox.consulting\/talent\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/brainbox.consulting\/talent\/wp-json\/wp\/v2\/comments?post=3791"}],"version-history":[{"count":13,"href":"https:\/\/brainbox.consulting\/talent\/wp-json\/wp\/v2\/posts\/3791\/revisions"}],"predecessor-version":[{"id":3810,"href":"https:\/\/brainbox.consulting\/talent\/wp-json\/wp\/v2\/posts\/3791\/revisions\/3810"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/brainbox.consulting\/talent\/wp-json\/wp\/v2\/media\/2472"}],"wp:attachment":[{"href":"https:\/\/brainbox.consulting\/talent\/wp-json\/wp\/v2\/media?parent=3791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/brainbox.consulting\/talent\/wp-json\/wp\/v2\/categories?post=3791"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/brainbox.consulting\/talent\/wp-json\/wp\/v2\/tags?post=3791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}