<?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 Mahesh Ganegoda on Medium]]></title>
        <description><![CDATA[Stories by Mahesh Ganegoda on Medium]]></description>
        <link>https://medium.com/@maheshganegoda?source=rss-d130766d8022------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*TorAn5cCuXhTXTO-eQgcCA.png</url>
            <title>Stories by Mahesh Ganegoda on Medium</title>
            <link>https://medium.com/@maheshganegoda?source=rss-d130766d8022------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 07:46:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@maheshganegoda/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[Fast Execution Cycles of UI Automation]]></title>
            <link>https://medium.com/@maheshganegoda/architectural-insights-fast-execution-cycles-of-test-automation-f04ee7dab65a?source=rss-d130766d8022------2</link>
            <guid isPermaLink="false">https://medium.com/p/f04ee7dab65a</guid>
            <category><![CDATA[quick-delivery]]></category>
            <category><![CDATA[parallel-execution]]></category>
            <category><![CDATA[test-automation]]></category>
            <dc:creator><![CDATA[Mahesh Ganegoda]]></dc:creator>
            <pubDate>Sun, 06 Feb 2022 10:02:58 GMT</pubDate>
            <atom:updated>2022-02-06T16:55:12.768Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*r_vFrNF1pn2mB3qtqHkOYA.jpeg" /></figure><p>The fast execution cycle of thousands of automated tests will enable you to make quick deliveries in the software life cycle. Perhaps if you compromise with other robust automation pipelines to propagate the builds into different environments and do necessary validations you will end up with continuous integration or continuous delivery of the software.</p><p>Achieving fast execution cycles may challenging because of the practice, application architecture, and automation architecture.</p><p>Let&#39;s see what are the things need to focus on in the automation architecture to achieve a fast execution cycle.</p><p><strong>Test structuring to support parallelization</strong></p><p>It’s clear that the capability of parallel execution of tests is key in this matter. The problem here is whether a test can be executed in an individual and isolated manner at a given time or is dependent on another test or sequence of tests.</p><p>In that case when designing the test it needs to decide parallel execution going to happen in terms of parallel classes(files) or parallel methods(different methods/tests in a file). Based on that before and after configuration also should apply accordingly. Avoiding dependent test make more easiness and flexibility for parallelization.</p><p>Another thing will be the number of tests that are going to include in a file if you suppose to have more than one test in a file. How much of parallel threads do you support for parallel execution and the average time is taken to execute all the tests in a file are the facts to consider having some optimal value. On the other hand, it is a best practice to limit the number of lines in a file which increases the readability of the code.</p><p>Most of the time it&#39;s recommended to have one concrete test in a file and support parallelization. Given that, avoiding duplicated implementations is also important to have high maintainability of the code. Following best practices of tools and their language techniques will help to overcome that challenge.</p><p>When comes to parallelization, different tools may have specific approaches and levels that support it.</p><p>Eg :</p><p>In Selenium using TestNG — <a href="https://testng.org/doc/documentation-main.html#parallel-running">https://testng.org/doc/documentation-main.html#parallel-running</a></p><p>Cypress — <a href="https://docs.cypress.io/guides/guides/parallelization#Overview">https://docs.cypress.io/guides/guides/parallelization#Overview</a></p><p><strong>Test data handling to support parallelization</strong></p><p>Just enabling parallel executions not going to be successful if the test data usage across multiple tests is not handled properly. Because it may limit parallel execution or blocked it completely.</p><p><em>Unique user for a test</em></p><p>It’s important to have a unique user to a test as multiple sessions for a given time are probably prohibited by the application itself. Hence the use of the same user for multiple tests may occur problems in parallel executions. Even though the user is unique for a test it shouldn’t create a new user always for each executions cycle. Because it will result in unnecessary data growth in DB. So it can have a logic to check for the existence of the user before creating or should be get deleted within configuration(after) data clean up.</p><p><em>Unique resource(s) for a test</em></p><p>Not only the users but the resources also get updated during the test execution may need to be isolated for a particular test. Otherwise, the same resources may be going to manipulate at the same time by parallel tests. These resources can be created on-demand as prerequisites in the test or can utilize already created resources that have the desired state for that test. If it’s created on the go it&#39;s mandatory to clean up in the teardown of the test to avoid any data conflicts in subsequent executions and for unnecessary data growth.</p><p><em>Offline resource creation if it takes considerable time</em></p><p>Sometimes resource creation takes considerable time especially when the process depends on different other systems. Then it’s a good idea to have an offline schedule script to create new resources that ensure there are enough resources available in the environment at the time of the full execution cycle start. Then it’s a matter of picking existing resources and getting utilized for a particular test, but it’s needed to make sure the same resource is not available to pick by another test again.</p><p>Parallel execution reduces the execution time of a set of tests. But what are the techniques that help to reduce the execution time of a single test? In that aspect also you will be able to reduce the time of an execution cycle.</p><p><strong>Bypass UI flow using the direct backend API call</strong></p><p>The use of backend API calls instead of UI flows to establish the state of a user journey will be a smart option to reduce the execution time of a particular test. Obviously, automation on the API level is much faster instead of simulating user steps through UI where it allows to bypass time taken UI steps and load only the intended UI directly where the validation is required for the test case or proceed to the next steps. In a process where a state is maintained in the backend is more feasible to have this approach in the automation.</p><p><strong>Handling waits for UI element interaction</strong></p><p>Sometimes tools do not by default handle the waits till the new element is loaded upon action on the page. Having thread sleeps or explicit timeouts for these waits not going to help for quick executions.</p><p>In a tool like Selenium WebDriver, it&#39;s always better to use implicit waits where it’s only waiting till the condition is satisfied. Tools like Cypress where the real browser is used the element visibility is already taken into account to make interactions where the waits are already handled.</p><p>Depending on the application architecture and its context there may be more options that can think of improving execution time while keeping the same conditions that can occur from real user behavior.</p><p>Consideration of the above factors from the beginning of the project will prevent you from having issues in test execution scaling.</p><p>Cheers,</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f04ee7dab65a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reusable & Maintainable UI Automation Code]]></title>
            <link>https://medium.com/@maheshganegoda/reusable-maintainable-ui-automation-code-6430bd4507b3?source=rss-d130766d8022------2</link>
            <guid isPermaLink="false">https://medium.com/p/6430bd4507b3</guid>
            <category><![CDATA[agile-testing]]></category>
            <category><![CDATA[page-object-pattern]]></category>
            <category><![CDATA[design-thinking]]></category>
            <category><![CDATA[ui-automation-testing]]></category>
            <category><![CDATA[selenium]]></category>
            <dc:creator><![CDATA[Mahesh Ganegoda]]></dc:creator>
            <pubDate>Sun, 29 Mar 2020 05:26:44 GMT</pubDate>
            <atom:updated>2020-03-30T12:41:35.003Z</atom:updated>
            <content:encoded><![CDATA[<p>The Agile development process drives the iterative development of software and makes a high demand for automation with the inclusion of software test automation. UI (User Interface) test automation can be a challenging task when it must change or update the automation code according to the new development or enhancements. So, high <strong><em>maintainable</em></strong> and <strong><em>reusable</em></strong> test automation code will be highly valuable for Agile testing practices.</p><blockquote>Test code is also a program.</blockquote><p>Let’s find out how a <strong>programming technique</strong> and one of the <strong>design concepts</strong> will help on improving the above factors for an automation code.</p><h3><strong>1. Parametrize</strong> <strong>the implementation for generalized user actions</strong></h3><p>First, we need to generalize the user actions. Let’s take an example.</p><p>Think about the web page which has tabs for some user selection</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*WHOyUK0Zr_ZEA4QHznWmkw.png" /><figcaption>Web page with tabs</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*AhxQUo6cDegxGarG7ekORA.png" /><figcaption><strong>Html source for above tabs</strong></figcaption></figure><p>You can clearly see three user actions normal users would do.</p><p>Action 1: Select tab “One”</p><p>Action 2: Select tab “Two”</p><p>Action 3: Select tab “Three”</p><p>If you are following the page object design pattern and use Java-Selenium, then you would have three methods in a page object class as follows</p><pre>public void selectTabOne(){<br>}<br>public void selectTabTwo(){<br>}<br>public void selectTabThree(){<br>}</pre><p>But how about have a generalized user action as “Select a tab” instead of three individual user actions?</p><p>We can do parametrize implementation with a method for this generalize “Select a tab” action as follows.</p><pre>public void selectTab(String tabName){<br>}</pre><p>Then think about how the implementation should be. We need to define locators to identify the UI element and do click action. First, think about Action1 (Select tab “One”)</p><pre>//locator for tab &quot;one&quot;<br>By tabLocator = By.xpath(&quot;//button/span[text()=&#39;One&#39;]&quot;);<br>public void selectTab(String tabName){<br>    driver.findElement(tabLocator).click();<br>}</pre><p>Now for the generalize action, this locator will not be fulfilled requirement. Hence locator also needs to be parameterized in a way it can align with the parameter value of the method as follows.</p><pre>//string for common xpath<br>String tabLocator = &quot;//button/span[text()=&#39;tab&#39;]&quot;;<br>public void selectTab(String tabName){<br>    //replace the string &quot;tab&quot;<br>    String currentTab = tabLocator.replace(&quot;tab&quot;,tabName); <br>    driver.findElement(By.xpath(currentTab)).click();<br>}</pre><p>Why it is reusable?</p><p>This method can use in multiple test cases by just changing parameters that can decide upon which user flow you going to automate. There can be test cases that need to access single tabs like “tab one” or multiple tabs in the single-user flow.</p><p>Why it is maintainable?</p><p>Assume there is a new tab (Four) available and you need to automate the action “Select tab “Four”. Because of the generalized method you just need to pass the new tab name as a parameter in order to automate click action on the tab “Four” as follows.</p><p>selectTab(“Four”);</p><p>This approach can be used for any kind of selection that the user would do. Technically it may be drop-down, checkbox and radio button, etc.</p><h3><strong>2. A Page-Object design pattern that facilitates parent user actions with the use of inheritance (OOP concept)</strong></h3><p>What are the parent user actions?</p><p>Web applications probably have some user actions that can perform at anytime even users navigate to different pages. As an example, the user may able to log out after navigating to any page of the application by selection top menu option which is normally available. It can have a header menu or left navigation menu which giving main navigation options to users from a single view.</p><blockquote><strong>The problem is, are we leveraging same user capabilities to the automation code?</strong> If yes the automation code will be reusable and maintainable. Why because, what you have to automate in test suite is nothing but those user capabilities in a given order.</blockquote><p>Let&#39;s see how inheritance as an OOP concept solves this problem technically.</p><p>Let’s understand with an example. Think about page-object design pattern for following “SharePoint” UI</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q5olbL_e9xBaEDwrTNzIWQ.png" /></figure><p>This has a top menu option and also a left navigation panel. Home page, Conversations page, Documents page… , etc are the page objects that can consider under page-object design pattern as it will load different content when selecting a left navigation option. Click profile, click settings and click notification will be <strong>parent actions</strong> in the top menu. “ClickLeftNavOption” is the <strong>generalize parent action </strong>that can think about the left navigation panel.</p><p>The technical goal is to invoke the methods of any parent actions through any of the page-object instances. That&#39;s where the inheritance will help us.</p><p>You can have an inheritance of parent actions in different ways. The following are two options that you can go with.</p><p><strong>Option 1</strong></p><p>Implement methods for parent actions in the supper class as a base page for every other page. Technically every other class which represents the other page objects can extend from this supper class.</p><p>Supper Class</p><pre>public class BasePage {<br><br>    public void clickSetings(){<br>    }<br><br>    public void clickProfile(){<br>    }<br><br>    public void clickLeftNavOption(String pageName){<br>    }<br>}</pre><p>Other page objects can extend from supper class to inherit parent user actions</p><pre>public class HomePage extends BasePage {<br>    <br>}</pre><pre>public class ConversationsPage extends BasePage {<br>    <br>}</pre><p><strong>Option 2</strong></p><p>It can have page-objects only to declare the user actions of the header menu and another page-objects to the left navigation panel in the same way. Then two page-objects can instantiate in a supper class and have object type variables. Then parent actions can accessible by child page-objects through those variables.</p><p>Page-Object for header menu</p><pre>public class HeaderMenuPage {<br>    public void clickSetings(){<br>    }<br><br>    public void clickProfile(){<br>    }<br>}</pre><p>Page-Object for the left navigation</p><pre>public class LeftNavigationPage {<br><br>    public void clickLeftNavOption(String pageName){<br>    }<br><br>}</pre><p>Supper class</p><pre>public class BasePage {<br><br>    public HeaderMenuPage headerMenuPage = new HeaderMenuPage();<br>    public LeftNavigationPage leftNavigationPage = new LeftNavigationPage();<br>    <br>}</pre><p>There are many other programming design techniques or concepts that will help to improve the reusability and maintainability of your test code depending on the context of your application and the tools that you used to automate.</p><blockquote><em>Don’t just automate, but do smart automaton.</em></blockquote><p>Cheers,</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6430bd4507b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>