<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sri Sundar on Medium]]></title>
        <description><![CDATA[Stories by Sri Sundar on Medium]]></description>
        <link>https://medium.com/@srissundar22?source=rss-57815bae8bf1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*7GPbGQ-NO1bqJPL5</url>
            <title>Stories by Sri Sundar on Medium</title>
            <link>https://medium.com/@srissundar22?source=rss-57815bae8bf1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 03:27:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@srissundar22/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Selenium Execution Taking Too Long ???]]></title>
            <link>https://medium.com/@srissundar22/selenium-execution-taking-too-long-c3112851dc19?source=rss-57815bae8bf1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3112851dc19</guid>
            <category><![CDATA[xpath]]></category>
            <category><![CDATA[parallel-testing]]></category>
            <category><![CDATA[selenium-test-automation]]></category>
            <category><![CDATA[explicit-wait]]></category>
            <dc:creator><![CDATA[Sri Sundar]]></dc:creator>
            <pubDate>Sat, 26 Feb 2022 22:57:37 GMT</pubDate>
            <atom:updated>2022-02-27T00:12:59.403Z</atom:updated>
            <content:encoded><![CDATA[<h3>Selenium Execution Taking Too Long ???</h3><p>Most common concern I have come across is the time it takes for the test cases execution to complete. In this blog I want to share some of the techniques that helped me in my projects.</p><p><strong>Parallel Testing</strong></p><p>Out of all the techniques this is the easiest one to speed up execution of Selenium test cases. Simply run automated tests on different device-browser-Operating System combinations simultaneously, so that the entire test suite can be completed in much lesser time.</p><p>If there are multiple tests to be run, execute each one on a different device at the same time or even better is to use the “parallel” attribute of suite tag that controls the number of instances running to execute multiple tests simultaneously or in parallel.</p><p>The parallel attribute for on the &lt;suite&gt; tag can accept one of the following values:</p><p>&lt;suite name = “Parallel Test” parallel = “methods” thread-count = “4”&gt;<br>&lt;suite name = “Parallel Test” parallel = “classes” thread-count = “4”&gt;<br>&lt;suite name = “Parallel Test” parallel = “tests” thread-count = “4”&gt;<br>&lt;suite name = “Parallel Test” parallel = “instances” thread-count = “4”&gt;</p><p>The second technique that can help with fast-tracking the execution is using Implicit/Explicit wait commands.</p><p><strong>Use only Explicit Waits as this would save a lot of time for you</strong></p><p>Explicit wait command for automation testing will eliminate any unnecessary slowdown and allow you to carry out wait conditions like ‘Element is visible’, ‘Element is Clickable’, ‘Element is Selectable’ on-page Web Elements, which is not possible in the case of Implicit Wait in Selenium. For example, the ‘ToBe Clickable’ method yields a Web Element when the identified element is clickable. Explicit wait retreats as soon as the condition is fulfilled. It means the element is returned as a result and does not wait for the entire time duration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ma53HTul5VAS95wFFNDq6g.png" /></figure><p>By all means my recommendation is to <strong>AVOID Thread .sleep().</strong></p><p>Thread .sleep causes the current thread to suspend execution for a specified period, say 5 seconds. We make WebDriver to wait for 5 seconds no matter what. What if search result appears in just a second? WebDriver will still wait for another 4 seconds. It will increase test execution time.</p><p>We need to pass wait time in advance to sleep method. What if search result appears after 6 seconds. Our script will fail again. We can not keep updating scripts with different values.</p><p><strong>Use fast selectors in test scripts</strong></p><p>When locating an element, start with the fast locators:<br>1. Locate element by ID : This works if the html element has the id attribute.<br>2.Locate element by Name : This works if the element has a name attribute.<br>3.Use a CSS selector : It is faster than XPATH but not as flexible.<br>4. Use an Xpath selector :This is the most flexible strategy for building locators.</p><p>Xpath selectors are slow as the page browser DOM is traversed for finding elements. It is important that the script uses as few elements as possible, especially if using XPATH locators.</p><p><strong>Use the same browser instance in many test possible</strong></p><p>One of most expensive things in testing with Selenium, or any other framework that opens a real browser, is the time it takes to open the browser. Why? Because it opens a new process on the computer, and this takes time. Exactly like the time it takes you to open the Google Chrome browser manually.</p><p>We are talking about several seconds each time! To handle this issue, prefer using the same browser instance for several tests instead of closing and opening each test. When using Java and TestNG, we can open the browser in the test class inside the method annotated with @BeforeClass. This will open the browser before the first test in the class runs. Only once. Much faster than opening it in every test all over again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JBgkiqaXtHyyyS2tog5Fhw.png" /></figure><p>I believe these tips would help you optimize the execution time for test cases using Selenium.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3112851dc19" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>