{"id":5085,"date":"2021-10-06T04:12:41","date_gmt":"2021-10-06T04:12:41","guid":{"rendered":"https:\/\/studysection.com\/blog\/?p=5085"},"modified":"2021-10-06T06:53:39","modified_gmt":"2021-10-06T06:53:39","slug":"parallel-test-execution-using-selenium-testng","status":"publish","type":"post","link":"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/","title":{"rendered":"Parallel Test Execution using Selenium TestNG"},"content":{"rendered":"<p>Parallel testing is a process of running the test cases or modules simultaneously rather than consecutively on different threads. The TestNG framework allows us to execute multiple test cases parallel over different environments instead of running test cases one after another. It helps to reduce the testing time and effort.<\/p>\n<p>TestNG provides different ways to execute tests in separate threads by using the parallel attribute in the testng.xml file. Where we can set the parallel attribute to method, tests, and classes.<br \/>\n<code>&lt;suite name=\"Suite\" parallel = \"methods\">...&lt;\/suite><\/code><br \/>\nHere, all the methods with Test annotation will execute parallel.<\/p>\n<h2>The parallel test attribute can accept only four values:<\/h2>\n<ol>\n<li><em>Tests <\/em>\u2013 All the tests inside the test tag will run parallel.<\/li>\n<li><em>Classes <\/em>\u2013 All the tests inside a java class will run parallel.<\/li>\n<li><em>Methods <\/em>\u2013 All the methods with test annotation will execute parallel.<\/li>\n<li><em>Instances <\/em>\u2013 Tests in the same instance will execute parallel.<\/li>\n<\/ol>\n<p><strong>Example:<\/strong> Here is an example of a webner solutions <a href=\"https:\/\/studysection.com\/blog\/key-points-while-designing-a-website\/\">website<\/a> that will execute on different browsers simultaneously and check the loading time.<\/p>\n<p><strong><em>Code:<\/em><\/strong><br \/>\n<code>package TA;<br \/>\nimport org.apache.commons.lang3.time.StopWatch;<br \/>\nimport org.openqa.selenium.WebDriver;<br \/>\nimport org.openqa.selenium.chrome.ChromeDriver;<br \/>\nimport org.openqa.selenium.edge.EdgeDriver;<br \/>\nimport org.openqa.selenium.firefox.FirefoxDriver;<br \/>\nimport org.testng.annotations.Test;<br \/>\nimport io.github.bonigarcia.wdm.WebDriverManager;<br \/>\npublic class ParallelExcution {<br \/>\nWebDriver driver;<br \/>\n@Test<br \/>\npublic void googleChrome() {<br \/>\n\tWebDriverManager.chromedriver().setup();<br \/>\n\tdriver = new ChromeDriver();<br \/>\n\tURL();<br \/>\n}<br \/>\n@Test<br \/>\npublic void mozillaFirefox() {<br \/>\n\tWebDriverManager.firefoxdriver().setup();<br \/>\n\tdriver = new FirefoxDriver();<br \/>\n\tURL();<br \/>\n}<br \/>\n@Test<br \/>\npublic void edge() {<br \/>\n\tWebDriverManager.edgedriver().setup();<br \/>\n\tdriver = new EdgeDriver();<br \/>\n\tURL();<br \/>\n}<br \/>\npublic void URL() {<br \/>\n\tStopWatch pageLoad = new StopWatch();<br \/>\n\tdriver.manage().window().maximize();<br \/>\n\tpageLoad.start();<br \/>\n\tdriver.get(\"https:\/\/webnersolutions.com\/\");<br \/>\n\tpageLoad.stop();<br \/>\n\tlong pageLoadTime = pageLoad.getTime()\/1000;<br \/>\n\tSystem.out.println(pageLoadTime + \"seconds\");<br \/>\n\tdriver.quit();<br \/>\n}<br \/>\n}<\/code><\/p>\n<p><strong><em>XML File:<\/em><\/strong><br \/>\n<code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?><br \/>\n&lt;!DOCTYPE suite SYSTEM \"https:\/\/testng.org\/testng-1.0.dtd\"><br \/>\n&lt;suite name=\"Suite\" parallel = \"methods\"><br \/>\n  &lt;test thread-count=\"10\" name=\"Test\"><br \/>\n    &lt;classes><br \/>\n      &lt;class name=\"TA.ParallelExcution\"\/><br \/>\n    &lt;\/classes><br \/>\n  &lt;\/test> &lt;!-- Test --><br \/>\n&lt;\/suite> &lt;!-- Suite --><\/code><\/p>\n<p><strong>Result:<\/strong><br \/>\n<img decoding=\"async\" src=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/output.png\" alt=\"TestNG\"\/><\/p>\n<p><small><em>People having good command over the French language can get a French certification from StudySection. StudySection offers both beginner level and expert level <a href=\"https:\/\/www.studysection.com\/french-language-and-concepts-advanced\">French Certification Exams<\/a> to test the ability to communicate in the French language.<\/em><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Parallel testing is a process of running the test cases or modules simultaneously rather than consecutively on different threads. The<\/p>\n","protected":false},"author":1,"featured_media":5086,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Parallel Test Execution using Selenium TestNG - SS Blog<\/title>\n<meta name=\"description\" content=\"Parallel testing is a process of running the test cases or modules simultaneously rather than consecutively on different threads.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Parallel Test Execution using Selenium TestNG - SS Blog\" \/>\n<meta property=\"og:description\" content=\"Parallel testing is a process of running the test cases or modules simultaneously rather than consecutively on different threads.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog Posts on famous people, innovations and educational topics\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/studysection\" \/>\n<meta property=\"article:published_time\" content=\"2021-10-06T04:12:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-10-06T06:53:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/Selenium.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"300\" \/>\n\t<meta property=\"og:image:height\" content=\"200\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin-studysection-blog\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@studysection\" \/>\n<meta name=\"twitter:site\" content=\"@studysection\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin-studysection-blog\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/\"},\"author\":{\"name\":\"admin-studysection-blog\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\"},\"headline\":\"Parallel Test Execution using Selenium TestNG\",\"datePublished\":\"2021-10-06T04:12:41+00:00\",\"dateModified\":\"2021-10-06T06:53:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/\"},\"wordCount\":210,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"articleSection\":[\"Learn and Grow\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/\",\"url\":\"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/\",\"name\":\"Parallel Test Execution using Selenium TestNG - SS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/studysection.com\/blog\/#website\"},\"datePublished\":\"2021-10-06T04:12:41+00:00\",\"dateModified\":\"2021-10-06T06:53:39+00:00\",\"description\":\"Parallel testing is a process of running the test cases or modules simultaneously rather than consecutively on different threads.\",\"breadcrumb\":{\"@id\":\"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/studysection.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Parallel Test Execution using Selenium TestNG\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/studysection.com\/blog\/#website\",\"url\":\"https:\/\/studysection.com\/blog\/\",\"name\":\"Blog Posts on famous people, innovations and educational topics\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/studysection.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/studysection.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/studysection.com\/blog\/#organization\",\"name\":\"StudySection\",\"url\":\"https:\/\/studysection.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png\",\"contentUrl\":\"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png\",\"width\":920,\"height\":440,\"caption\":\"StudySection\"},\"image\":{\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/studysection\",\"https:\/\/twitter.com\/studysection\",\"https:\/\/www.instagram.com\/study.section\/\",\"https:\/\/www.linkedin.com\/company\/studysection\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402\",\"name\":\"admin-studysection-blog\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/studysection.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g\",\"caption\":\"admin-studysection-blog\"},\"url\":\"https:\/\/studysection.com\/blog\/author\/admin-studysection-blog\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Parallel Test Execution using Selenium TestNG - SS Blog","description":"Parallel testing is a process of running the test cases or modules simultaneously rather than consecutively on different threads.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/","og_locale":"en_US","og_type":"article","og_title":"Parallel Test Execution using Selenium TestNG - SS Blog","og_description":"Parallel testing is a process of running the test cases or modules simultaneously rather than consecutively on different threads.","og_url":"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/","og_site_name":"Blog Posts on famous people, innovations and educational topics","article_publisher":"https:\/\/www.facebook.com\/studysection","article_published_time":"2021-10-06T04:12:41+00:00","article_modified_time":"2021-10-06T06:53:39+00:00","og_image":[{"width":300,"height":200,"url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/Selenium.jpg","type":"image\/jpeg"}],"author":"admin-studysection-blog","twitter_card":"summary_large_image","twitter_creator":"@studysection","twitter_site":"@studysection","twitter_misc":{"Written by":"admin-studysection-blog","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/#article","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/"},"author":{"name":"admin-studysection-blog","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402"},"headline":"Parallel Test Execution using Selenium TestNG","datePublished":"2021-10-06T04:12:41+00:00","dateModified":"2021-10-06T06:53:39+00:00","mainEntityOfPage":{"@id":"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/"},"wordCount":210,"commentCount":0,"publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"articleSection":["Learn and Grow"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/","url":"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/","name":"Parallel Test Execution using Selenium TestNG - SS Blog","isPartOf":{"@id":"https:\/\/studysection.com\/blog\/#website"},"datePublished":"2021-10-06T04:12:41+00:00","dateModified":"2021-10-06T06:53:39+00:00","description":"Parallel testing is a process of running the test cases or modules simultaneously rather than consecutively on different threads.","breadcrumb":{"@id":"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/studysection.com\/blog\/parallel-test-execution-using-selenium-testng\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/studysection.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Parallel Test Execution using Selenium TestNG"}]},{"@type":"WebSite","@id":"https:\/\/studysection.com\/blog\/#website","url":"https:\/\/studysection.com\/blog\/","name":"Blog Posts on famous people, innovations and educational topics","description":"","publisher":{"@id":"https:\/\/studysection.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/studysection.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/studysection.com\/blog\/#organization","name":"StudySection","url":"https:\/\/studysection.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png","contentUrl":"https:\/\/studysection.com\/blog\/wp-content\/uploads\/2021\/10\/studySection-logo.png","width":920,"height":440,"caption":"StudySection"},"image":{"@id":"https:\/\/studysection.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/studysection","https:\/\/twitter.com\/studysection","https:\/\/www.instagram.com\/study.section\/","https:\/\/www.linkedin.com\/company\/studysection"]},{"@type":"Person","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/db367e2c29a12d1808fb1979edb3d402","name":"admin-studysection-blog","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/studysection.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/054ac87a6874df1932004239cd8eab36?s=96&d=mm&r=g","caption":"admin-studysection-blog"},"url":"https:\/\/studysection.com\/blog\/author\/admin-studysection-blog\/"}]}},"views":494,"_links":{"self":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/5085"}],"collection":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/comments?post=5085"}],"version-history":[{"count":5,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/5085\/revisions"}],"predecessor-version":[{"id":5092,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/posts\/5085\/revisions\/5092"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media\/5086"}],"wp:attachment":[{"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/media?parent=5085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/categories?post=5085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/studysection.com\/blog\/wp-json\/wp\/v2\/tags?post=5085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}