{"id":6216,"date":"2017-08-28T02:36:43","date_gmt":"2017-08-28T02:36:43","guid":{"rendered":"http:\/\/www.jitendrazaa.com\/blog\/?p=6216"},"modified":"2017-08-30T16:44:00","modified_gmt":"2017-08-30T16:44:00","slug":"performing-load-testing-in-salesforce-using-selenium-and-testng","status":"publish","type":"post","link":"https:\/\/www.jitendrazaa.com\/blog\/java\/performing-load-testing-in-salesforce-using-selenium-and-testng\/","title":{"rendered":"Performing Load Testing in Salesforce using Selenium and TestNG"},"content":{"rendered":"<p style=\"text-align: justify;\">When we build any custom solution in Salesforce, key is to write <a href=\"https:\/\/www.jitendrazaa.com\/blog\/tag\/testclass\/\">an efficient and meaningful Apex test classes<\/a> for sure. However sometime we may need to test how custom application would behave in maximum operating capacity. Here, I am talking about <a href=\"https:\/\/en.wikipedia.org\/wiki\/Load_testing\">Load Testing<\/a> of custom applications built on top of Force.com platform. Recently I needed to push my code to its limit to know how many concurrent users can use it before hitting any governor limits. Quickly I realize that its time to call my friends <a href=\"http:\/\/www.seleniumhq.org\/\">Selenium<\/a> and <a href=\"http:\/\/testng.org\/doc\/\">TestNG<\/a>.<\/p>\n<blockquote>\n<p style=\"text-align: justify;\">Before doing any extensive stress or load testing on Salesforce, we must need to contact Salesforce support and explain them what we are trying to achieve. More detail available in <a href=\"https:\/\/developer.salesforce.com\/blogs\/engineering\/2013\/09\/performance-testing-force-com-application.html?lipi=urn%3Ali%3Apage%3Ad_flagship3_detail_base%3BqYlSS%2BBPQvOZlFXmzfDdxA%3D%3D\">this official Salesforce blog post<\/a>.<\/p>\n<\/blockquote>\n<p style=\"text-align: justify;\">I have published <a href=\"https:\/\/www.jitendrazaa.com\/blog\/tag\/Selenium\/\">some blog posts about Selenium<\/a> in past as well however whats different this time ? I need to determine after how many simultaneous user interactions, I would hit\u00a0<strong><a href=\"https:\/\/developer.salesforce.com\/blogs\/engineering\/2015\/11\/avoiding-the-concurrent-request-limit-via-synchronous-callout-optimization.html\">Concurrent Apex Limit<\/a>\u00a0<\/strong>error as shown in below image.<\/p>\n<figure id=\"attachment_6218\" aria-describedby=\"caption-attachment-6218\" style=\"width: 507px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-6218\" src=\"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/08\/verifyLonGRunningProcess-1503878448160.png?resize=507%2C261&#038;ssl=1\" alt=\"Salesforce Governor Limit error - Concurrent Apex Limit\" width=\"507\" height=\"261\" srcset=\"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/08\/verifyLonGRunningProcess-1503878448160.png?w=507&amp;ssl=1 507w, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/08\/verifyLonGRunningProcess-1503878448160.png?resize=300%2C154&amp;ssl=1 300w\" sizes=\"auto, (max-width: 507px) 100vw, 507px\" \/><figcaption id=\"caption-attachment-6218\" class=\"wp-caption-text\">Salesforce Governor Limit error &#8211; Concurrent Apex Limit<\/figcaption><\/figure>\n<p><!--more--><\/p>\n<h5>How to perform Parallel execution of browsers in Selenium<\/h5>\n<p style=\"text-align: justify;\">I needed to launch around 20 instances of browsers with unique session Ids to see how my long running Apex code will behave.<\/p>\n<p style=\"text-align: justify;\">If you need quick tour, <a href=\"https:\/\/github.com\/JitendraZaa\/SeleniumParallelExecution\">visit this repository for complete source code, jars and browser drivers.<\/a> You can check this <a href=\"https:\/\/www.youtube.com\/watch?v=4H1kj8GUebw\">Youtube video<\/a> as well to see how it works.<\/p>\n<p style=\"text-align: justify;\">Key to solution is using <strong><a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/ThreadLocal.html\">Threadpool<\/a> <\/strong>to instantiate drivers and using <strong>@Test<\/strong> annotation of TestNG framework.<\/p>\n<p style=\"text-align: justify;\">Below sample Java class shows how to use <strong>Threadpool<\/strong> to instantiate selenium driver.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/JitendraZaa\/6f91c6d0a33e01663b56660796684821.js\"><\/script><\/p>\n<h5>Open multiple browsers in Selenium using TestNG to perform Parallel Testing<\/h5>\n<p style=\"text-align: justify;\">@Test(invocationCount = 20,threadPoolSize = 20) annotation is used in class <a href=\"https:\/\/github.com\/JitendraZaa\/SeleniumParallelExecution\/blob\/master\/src\/com\/jitendrazaa\/ConcurrentApexError.java\">ConcurrentApexError.java<\/a> to open 20 chrome browsers using Selenium. This annotation is part of <strong>TestNG<\/strong> framework.<\/p>\n<h5>How to take screenshots of Fail Test cases using TestNG in Selenium<\/h5>\n<p style=\"text-align: justify;\">Once all test suites completes execution, we need a proof on why test execution failed. What would be better than\u00a0<strong>automated screenshots\u00a0<\/strong>being taken by\u00a0<strong>TestNG\u00a0<\/strong>framework?\u00a0<em>takeScreenShotOnFailure()<\/em> method in class\u00a0<a href=\"https:\/\/github.com\/JitendraZaa\/SeleniumParallelExecution\/blob\/master\/src\/com\/jitendrazaa\/TestBase.java\">TestBase.java<\/a> takes screen shot of failure test cases.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/JitendraZaa\/6e0bf9e09bfe8063a49974be7ee6dbaf.js\"><\/script><\/p>\n<p>Hope this blog post will help you to some extend. Please don&#8217;t forget to leave a feedback.<\/p>\n<p><iframe loading=\"lazy\" title=\"Performing Load Testing in Salesforce using Selenium and TestNG\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/4H1kj8GUebw?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Parallel execution of browsers in Selenium with the help of TestNG and determining maximum operating capacity of custom code in Salesforce<\/p>\n","protected":false},"author":1,"featured_media":6217,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"jz_research_post":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,9],"tags":[303,305,422,423,212],"class_list":["post-6216","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","category-salesforce","tag-automated-testing","tag-selenium","tag-testng","tag-threadpool","tag-video-tutorial"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/08\/Selenium-Salesforce-load-Testing.jpg?fit=964%2C848&ssl=1","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":4366,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/getting-started-with-selenium-and-salesforce-salesforce-automation-testing-video-tutorial-part-1\/","url_meta":{"origin":6216,"position":0},"title":"Selenium and Salesforce &#8211; Salesforce automation testing &#8211; Video tutorial &#8211; Part 1","author":"Jitendra","date":"March 28, 2015","format":false,"excerpt":"This is first post of multi-series article on using Selenium with Salesforce for Automation testing. Testing has always been integral part of any software development life cycle and Salesforce has already taken it to next level by making mandatory to have 75% of code coverage before any code deployment. These\u2026","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"Sample Selenium Script","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/03\/Sample-Selenium-Script.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/03\/Sample-Selenium-Script.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/03\/Sample-Selenium-Script.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/03\/Sample-Selenium-Script.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":4402,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/using-selenium-to-test-workflow-field-update-action-salesforce-automated-testing-video-tutorial-part-2\/","url_meta":{"origin":6216,"position":1},"title":"Using Selenium to test workflow field update action &#8211; Salesforce automated testing &#8211; Video tutorial &#8211; Part 2","author":"Jitendra","date":"April 27, 2015","format":false,"excerpt":"We have already discussed\u00a0basics of selenium and how we can use this tool for automated testing.\u00a0Here we will see how we can take advantage of Selenium to test workflow field update. in this article we will create a simple workflow rule on Lead object and update \"Description\" field by adding\u2026","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"Salesforce Workflow rule - field update on Lead","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/04\/Salesforce-Workflow-rule-field-update-on-Lead.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/04\/Salesforce-Workflow-rule-field-update-on-Lead.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/04\/Salesforce-Workflow-rule-field-update-on-Lead.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/04\/Salesforce-Workflow-rule-field-update-on-Lead.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":7041,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/salesforce-load-testing-using-soapui\/","url_meta":{"origin":6216,"position":2},"title":"Salesforce Load Testing using SOAPUI","author":"Jitendra","date":"April 23, 2020","format":false,"excerpt":"Previously, I have added multiple posts in this blog on how you would face governor limit errors on each step of Salesforce implementation and how we can leverage selenium to perform load testing of Salesforce to some extent. SOAP UI is powerful tool and in this post we will see\u2026","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"API Load Testing using SOAPUI","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2020\/04\/API-Load-Testing-using-SOAPUI.png?fit=1029%2C529&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2020\/04\/API-Load-Testing-using-SOAPUI.png?fit=1029%2C529&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2020\/04\/API-Load-Testing-using-SOAPUI.png?fit=1029%2C529&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2020\/04\/API-Load-Testing-using-SOAPUI.png?fit=1029%2C529&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":4584,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/continuous-integration-in-salesforce-using-flosum-appexchange\/","url_meta":{"origin":6216,"position":3},"title":"Continuous Integration in Salesforce using Flosum AppExchange","author":"Jitendra","date":"June 22, 2015","format":false,"excerpt":"Native Force.com solution for Continuous Integration using AppExchange product Flosum","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"Flosum AppExchange","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/06\/Flosum-AppExchange.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/06\/Flosum-AppExchange.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/06\/Flosum-AppExchange.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/06\/Flosum-AppExchange.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":4501,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/using-soapui-with-salesforce-to-test-standard-and-custom-web-services-response\/","url_meta":{"origin":6216,"position":4},"title":"Using soapUI with Salesforce to test standard and custom web services response","author":"Jitendra","date":"May 27, 2015","format":false,"excerpt":"soapUI is most common tool available to test Soap based web services, it also has capability to test REST web services. soapUI can be used to test Partner WSDL, enterprise WSDL, Tooling API, Metadata API to study capability and response from Salesforce before writing any code in Java, C# or\u2026","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"Create New SoapUI project","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/05\/Create-New-SoapUI-project.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/05\/Create-New-SoapUI-project.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/05\/Create-New-SoapUI-project.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":5152,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/using-test-loaddata-to-import-records-with-relationship\/","url_meta":{"origin":6216,"position":5},"title":"Using Test.loadData to import records with relationship","author":"Jitendra","date":"January 6, 2016","format":false,"excerpt":"There are many resources and documents available around how to use Test.loadData to create test records in Apex class. As per best practice of writing Test classes in Apex, Its good idea to store master data (aka Seed, Reference data) in static resource and load\u00a0it in Test classes using \"Test.loadData\"\u2026","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"Test.loadData and Static resource in Salesforce","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2016\/01\/Test.loadData-and-Static-resource-in-Salesforce.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2016\/01\/Test.loadData-and-Static-resource-in-Salesforce.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2016\/01\/Test.loadData-and-Static-resource-in-Salesforce.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2016\/01\/Test.loadData-and-Static-resource-in-Salesforce.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/6216","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/comments?post=6216"}],"version-history":[{"count":3,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/6216\/revisions"}],"predecessor-version":[{"id":6230,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/6216\/revisions\/6230"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media\/6217"}],"wp:attachment":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media?parent=6216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/categories?post=6216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/tags?post=6216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}