<?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 Oruganti on Medium]]></title>
        <description><![CDATA[Stories by Mahesh Oruganti on Medium]]></description>
        <link>https://medium.com/@moruganti-33642?source=rss-4af4db048f23------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*cyqWiCql02gJfVEhyTIb2A.png</url>
            <title>Stories by Mahesh Oruganti on Medium</title>
            <link>https://medium.com/@moruganti-33642?source=rss-4af4db048f23------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 08:16:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@moruganti-33642/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[Migrating Selenium , Java Based JUnit 4 Automation Tests to JUnit 5]]></title>
            <link>https://moruganti-33642.medium.com/migrating-selenium-java-based-junit-4-automation-tests-to-junit-5-3f44a8611e5f?source=rss-4af4db048f23------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f44a8611e5f</guid>
            <dc:creator><![CDATA[Mahesh Oruganti]]></dc:creator>
            <pubDate>Mon, 28 Jun 2021 12:43:17 GMT</pubDate>
            <atom:updated>2021-06-28T12:43:17.959Z</atom:updated>
            <content:encoded><![CDATA[<h3>Migrating Selenium , Java Based JUnit 4 Automation Tests to JUnit 5</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mFt3wudVniuylpWZTFiVOw.png" /></figure><blockquote><strong>The objective of this post is to explain and share my experience migrating existing JUnit 4 Selenium, Java based Automation Tests or framework to JUnit 5.</strong></blockquote><p><strong><em>Our Story:</em></strong><em> It’s been 7 years we are running JUnit4 based automation tests(around 20,000+ regression tests for 20 + web applications in </em><a href="https://www.dotdash.com/"><strong><em>Dotdash</em></strong></a><em>) We also have well designed automation framework built on top of Selenium, Java based which supports for running all tests based on different browsers, devices, environments, operating systems and different test categories(smoke, regression, visual etc..). we run Automation Tests using docker containerization way . checkout my blog here </em><a href="https://techblog.dotdash.com/setting-up-a-selenium-grid-with-docker-containers-for-running-automation-tests-c43aceccd5d9"><strong>Setting up an on-demand Selenium Grid with containers.</strong></a></p><h3><strong>JUnit 4 Current Setup:</strong></h3><p>There are two ways we run tests.</p><blockquote><strong>1.</strong> Using IDE’s (Eclipse, IntelliJ etc..)</blockquote><blockquote><strong>2.</strong> Running through command line(just like running Java Application)by Jenkins pipeline with remote Selenium Grid.</blockquote><h3><strong>JUnit 5 Overview:</strong></h3><h4><strong>What is JUnit 5?</strong></h4><ul><li>JUnit 5 is a powerful and flexible update to the JUnit framework, and it provides a variety of improvements and new features to organize and describe test cases</li><li>Unlike previous versions of JUnit, JUnit 5 is composed of several different modules from three different sub-projects.</li><li><strong>JUnit 5 = <em>JUnit Platform</em> + <em>JUnit Jupiter</em> + <em>JUnit Vintage</em></strong></li><li><strong>JUnit Platform</strong> serves as a foundation for launching testing frameworks on the JVM.</li><li><strong>JUnit Jupiter</strong> is the combination of the new programming model and extension model for writing tests and extensions in JUnit 5. The Jupiter sub-project provides a TestEngine for running Jupiter based tests on the platform.</li><li><strong>JUnit Vintage</strong> provides a TestEngine for running JUnit 3 and JUnit 4 based tests on the platform.</li></ul><h4><strong>JUnit 5 Architecture &amp; Maven Dependency:</strong></h4><blockquote><em>please check all Junit5 Maven dependencies available from maven repository </em><a href="https://mvnrepository.com/artifact/org.junit.jupiter"><em>https://mvnrepository.com/artifact/org.junit.jupiter</em></a><em> .</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*efSHfk_eSBEA52BSzYqaug.png" /><figcaption>JUnit 5 Architecture &amp; Maven Dependency</figcaption></figure><h4>JUnit 5 Features:</h4><blockquote>JUnit 5 provided a lot of new features to write and run tests along with existing JUnit 4 features. I am not going to talk about each one but I have included some of the features in the sample code and explained differences below. To understand all of these features and changes for some of the JUnit4 Annotations, Assertions, Assumptions please go through the JUnit 5 user guide <a href="https://junit.org/junit5/docs/current/user-guide/">https://junit.org/junit5/docs/current/user-guide/</a> or refer sample code.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kqJWACLcr2h6O5obyeQn-w.png" /><figcaption><strong>JUnit 5 Features</strong></figcaption></figure><ol><li>Methods for asserting reside in the <strong>org.junit.jupiter.api.Assertions </strong>class instead of <strong>org.junit.Assert </strong>class.</li><li>Assumption methods reside in <strong>org.junit.jupiter.Assumptions</strong> class instead of <strong>org.junit.Assume</strong> class.</li><li>The <strong>@Category </strong>annotation from JUnit 4 has been replaced with a <strong>@Tag</strong> annotation in JUnit 5. Also, we no longer use marker interfaces but instead pass the annotation a string parameter or create Custom tags and use them. for example,</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*dOXSIncpU1O0duvqZxdVWQ.png" /><figcaption><strong>@Tag usage</strong></figcaption></figure><p><strong>4. Custom Tags:</strong> you can create custom Tags using <strong>@Tag</strong> and use for Tests. for example to create SmokeTests Tag and use later for the tests,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*REu8tm2-yYutyDvpr5pPgA.png" /><figcaption><strong>Custom Tags creation and usage</strong></figcaption></figure><p>5. you can also include <strong>@Test </strong>with custom Tag and directly use custom Tag(for example <strong>@RegressionTest</strong>) for Test. for example,</p><figure><img alt="Custom Tags creation and usage" src="https://cdn-images-1.medium.com/max/828/1*c3uznoXdg5o4U0UXZ48GMw.png" /><figcaption><strong>Custom Tags creation and usage</strong></figcaption></figure><p>6. In JUnit 4 writing parameterized tests required using a Parameterized runner. In addition, we needed to provide parameterized data via a method annotated with the <strong>@Parameterized.Parameters</strong> annotation.</p><p>7. <strong>Annotations :</strong> below are some changes made for existing JUnit4 annotations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*YJfdzqUliFRDMCWdfMT0Nw.png" /><figcaption><strong>Annotations changes</strong></figcaption></figure><h4><strong>Conditional Test execution:</strong></h4><ol><li>JUnit 5 provides the ExecutionCondition extension API to enable or disable a test or container (test class) conditionally. This is like using @Disabled on a test but it can define custom conditions. There are multiple built-in conditions, such as,</li></ol><p><strong>@EnabledOnOs and @DisabledOnOs: </strong>Enables or disables a test only on specified operating systems.</p><p><strong>@EnabledOnJre and @DisabledOnJre: </strong>Specifies the test should be enabled or disabled for particular versions of Java.</p><p><strong>@EnabledIfSystemProperty:</strong> Enables a test based on the value of a JVM system property.</p><p><strong>@EnabledIf:</strong> Uses scripted logic to enable a test if scripted conditions are met.</p><p><strong>@EnabledIfEnvironmentVariable and @DisabledIfEnvironmentVariable : </strong>enabled or disabled based on the value of the named environment variable.</p><p><strong>Custom conditions : </strong>@EnabledIf(“customCondition”) &amp; @DisabledIf(“customCondition”)</p><h4>JUnit 5 Features: Advanced:</h4><blockquote>These are the more interesting topics/features to discover and run tests. before migrating to JUnit5 , we were running JUnit 4 tests by identifying/scanning test classes at run time using Java reflection but now using theses JUnit 5 advanced features, we get rid of all old logic/code and it’s simple and easy way to understand, write code.</blockquote><ol><li><strong>JUnit Platform Launcher API</strong> : JUnit 5 introduces the concept of a Launcher that can be used to discover, filter, and execute tests. The launcher API is in the <a href="https://junit.org/junit5/docs/current/api/org.junit.platform.launcher/org/junit/platform/launcher/package-summary.html">junit-platform-launcher </a>module.</li><li><strong>Discovering Tests </strong>: Introducing <em>test discovery</em> as a dedicated feature of the platform itself will (hopefully) free IDEs and build tools from most of the difficulties they had to go through to identify test classes and test methods in the past.</li><li><strong>Executing Tests</strong> : To execute tests, clients can use the same LauncherDiscoveryRequest as in the discovery phase or create a new request. Test progress and reporting can be achieved by registering one or more <a href="https://junit.org/junit5/docs/current/api/org.junit.platform.launcher/org/junit/platform/launcher/TestExecutionListener.html">TestExecutionListener</a> implementations with the Launcher.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SofCVSZEx657rUcE59N61w.png" /><figcaption><strong>LauncherDiscoveryRequest</strong></figcaption></figure><p><strong>4. </strong>Here is sample example code in <strong>main()</strong> method to run regression tests, smoke tests and single tests from your project.</p><blockquote><strong>Note:</strong><em> </em><strong>XmlReportGeneratingListener</strong> used in main() method is a listener which extending <a href="https://junit.org/junit5/docs/current/api/org.junit.platform.launcher/org/junit/platform/launcher/TestExecutionListener.html"><strong>TestExecutionListener</strong></a> to log events for each test and generate test reports.you can use your own listener or JUnit5 provided <a href="https://junit.org/junit5/docs/current/api/org.junit.platform.launcher/org/junit/platform/launcher/TestExecutionListener.html"><strong>TestExecutionListener</strong></a>. I am not explaining more details about it.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0T5wsp-PMGuJfKl-gjZtNw.png" /><figcaption>main() method part -1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zGwAEWdJxM9-ev4msDcNRw.png" /><figcaption>main() method part -2</figcaption></figure><h3>Parallel Execution:</h3><blockquote>Note: Very Very Important topic.please read , understand and practice.</blockquote><p>By default, JUnit Jupiter tests are run sequentially in a single thread. Running tests in parallel, e.g. to speed up execution, is available as an opt-in feature since version 5.3.We can configure parallel tests execution for JUnit 5 tests in several ways,</p><ol><li>By providing parameters to <strong>maven surefire plugin</strong>. You can set JUnit Platform configuration parameters to influence test discovery and execution by declaring the configurationParameters property and providing key-value pairs using the Java Properties file syntax (as shown below). please add or delete configuration according to your requirements.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bgy5Dp5dBYvfr5ORq8qo2w.png" /><figcaption>mavn-surefire-plugin with JUnit5 parallel configuration</figcaption></figure><p><strong>2. By providing as System properties to JVM: </strong>In Java, you can set system properties either from the command line or from the application code itself. For example, to run only test methods in the org.example.MyTest test class you can execute mvn -Dtest=org.example.MyTest test from the command line or you can set property from the application like , <strong>System.setProperty(“test” , “org.example.MyTest”);</strong></p><p><strong>3</strong>. <strong>The JUnit Platform configuration file</strong>: The simplest way is include parameter <strong>junit.jupiter.execution.parallel.enabled=true </strong>in <strong>junit-platform.properties </strong>file (<strong>src/main/resources</strong>).</p><h4><strong>Configuration to execute top-level classes in parallel but methods in same thread.</strong></h4><blockquote>Note: You will notice from the out put that, each group of tests started by one different thread and each group test methods started by same thread. try to run the tests and check the console log to see differences.</blockquote><blockquote><strong>strategies</strong> take different approaches to configure the environment of the parallel execution, such as the number of threads to use. If no configuration strategy is set, JUnit Jupiter uses the dynamic configuration strategy with a factor of 1, i.e. the desired parallelism will equal the number of available processors/cores.</blockquote><h4><strong>The fixed strategy:</strong></h4><ul><li>The <strong>fixed</strong> strategy uses a hardcoded number of threads to drive parallel execution.To set this strategy, use configuration parameter junit.jupiter.execution.parallel.config.strategy=fixed</li><li>To configure <strong>fixed</strong> strategy, use configuration parameter junit.jupiter.execution.parallel.config.fixed.parallelism and set it to an int value.</li></ul><pre>junit.jupiter.execution.parallel.enabled = true<br>junit.jupiter.execution.parallel.mode.default = same_thread<br>junit.jupiter.execution.parallel.mode.classes.default = concurrent<br>junit.jupiter.execution.parallel.config.strategy = fixed<br>junit.jupiter.execution.parallel.config.fixed.parallelism = 10<br>junit.platform.output.capture.stdout = true<br>junit.platform.output.capture.stderr = true</pre><p><strong>Configuration to execute top-level classes in sequentially but their methods in parallel.</strong></p><blockquote>Note: You will notice from the out put that, each test class started sequentially and test methods are executed in parallel by different threads.</blockquote><pre>junit.jupiter.execution.parallel.enabled = true<br>junit.jupiter.execution.parallel.mode.default = concurrent<br>junit.jupiter.execution.parallel.mode.classes.default = same_thread<br>junit.jupiter.execution.parallel.config.strategy = fixed<br>junit.jupiter.execution.parallel.config.fixed.parallelism = 10<br>junit.platform.output.capture.stdout = true<br>junit.platform.output.capture.stderr = true</pre><h4><strong>Dynamic strategy:</strong></h4><ul><li><strong>Dynamic</strong> is the default parallel execution strategy.</li><li>It utilizes the number of CPU cores to determine parallelism.</li><li>To set this strategy explicitly, use configuration parameter junit.jupiter.execution.parallel.config.strategy=dynamic</li><li>To scale this value, use configuration parameter junit.jupiter.execution.parallel.config.dynamic.factor and set it to an int value (default: 1).</li></ul><pre>junit.jupiter.execution.parallel.enabled = true<br>junit.jupiter.execution.parallel.mode.default = concurrent<br>junit.jupiter.execution.parallel.mode.classes.default = same_thread<br>junit.jupiter.execution.parallel.config.strategy=dynamic<br>junit.jupiter.execution.parallel.config.dynamic.factor = 10<br>junit.platform.output.capture.stdout = true<br>junit.platform.output.capture.stderr = true</pre><h4><strong>Custom strategy:</strong></h4><ul><li>For developers that seek complete control over their concurrent execution, the implementation of a ParallelExecutionConfiguration is exposed to the TestEngine. This also provides a mechanism to consume custom configuration parameters passed to the JVM through the public API of the <a href="https://junit.org/junit5/docs/5.3.1/api/org/junit/platform/engine/support/hierarchical/ParallelExecutionConfigurationStrategy.html">ParallelExecutionConfigurationStrategy</a> class.</li><li>To write a custom execution strategy, a dependency on the junit-platform-engine library is required inside the test project.</li><li>To set this strategy explicitly, use configuration parameter . junit.jupiter.execution.parallel.config.strategy = custom</li><li>Use configuration parameter junit.jupiter.execution.parallel.config.custom.class and set it to the implementation class.</li><li>If the strategy requires more external data, it can define its own configuration parameters. The name is arbitrary, but it must start with the &quot;junit.jupiter.execution.parallel.config&quot; prefix. below is sample code.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O7zwxjgXzhjvzz2QvBXR6A.png" /><figcaption>custom strategy</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ua9Dpb-w6LxgpFsEZ03rng.png" /><figcaption>implementing ParallelExecution Configuration , Strategy</figcaption></figure><h4>Capturing Standard Output/Error:</h4><p>Since version 1.3, the JUnit Platform provides opt-in support for capturing output printed to System.out and System.err. To enable it, simply set the <strong>junit.platform.output.capture.stdout </strong>and/or <strong>junit.platform.output.capture.stderr</strong> configuration parameter to <strong>true</strong>.</p><h3>Extension Model</h3><p>The @Rule and @ClassRule annotations from JUnit 4 do not exist in JUnit 5. We can implement the same functionality by using the new extension model in the org.junit.jupiter.api.extension package and the @ExtendWith annotation.</p><p>In contrast to the competing <strong>Runner</strong>, <strong>@Rule</strong>, and <strong>@ClassRule</strong> extension points in JUnit 4, the JUnit Jupiter extension model consists of a single, coherent concept: the <strong>Extension</strong> API. Developers can register one or more extensions declaratively by annotating a test interface, test class, test method, or custom composed annotation with <strong>@ExtendWith(…) </strong>and supplying class references for the extensions to register.</p><p>we have a requirement that need to post/delete some document Json data to document database before/after running tests. we were using @Rule in JUnit4 . now we have achieved same with implementing <strong>BeforeEachCallback , AfterEachCallback </strong>and registering extensions declaratively by annotating a test<strong> </strong>class/test with<strong> @ExtendWith.</strong></p><p>@ExtendWith is a repeatable annotation that is used to register extensions for the annotated test class or test method. for example if you want to implement @ExtendWith at class level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*60y2mXOHBeeF3wID0F6TXA.png" /><figcaption>Implementing Test data rule</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-IfZElMg8b2nTDuuR8CiIA.png" /></figure><p>we can also use @ExtendWith at test level, for example,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*qPVOQTB3aQj56eaAfxlm-w.png" /></figure><h3>ErrorCollector:</h3><p>The ErrorCollector rule allows execution of a test to continue after the first problem is found (for example, to collect _all_ the incorrect rows in a table, and report them all at once). we have been using ErrorCollector with <a href="http://hamcrest.org/JavaHamcrest/javadoc/1.3/org/hamcrest/Matchers.html">hamcrest matchers</a> to report test failures. example code is here in my test method,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZCiOBe8fFaPD3C6224AKOQ.png" /></figure><p>JUnit5 has provided some solution to migrate/convert test assertions. here is example ,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bPdS0nlwtB332cfpUBNleQ.png" /></figure><p>you can find all JUnit5 Assertions over <a href="https://junit.org/junit5/docs/5.3.0/api/org/junit/jupiter/api/Assertions.html">here</a></p><p>But after moving to Junit5, we could not able to migrate all test assertions using the above provided solution and we thought that it involves lot of code refactoring .</p><p>However, to provide a gradual migration path there is support for a subset of JUnit 4 rules and their subclasses in junit-jupiter-migrationsupport module.</p><p>Existing code using these rules can be left unchanged by using the class level annotation @EnableRuleMigrationSupport in the org.junit.jupiter.migrationsupport.rules package.</p><p>To enable the support in Maven we have to add the below dependency in pom.xml.</p><pre>&lt;dependencies&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;<br>        &lt;artifactId&gt;junit-jupiter-migrationsupport&lt;/artifactId&gt;<br>        &lt;version&gt;5.7.0&lt;/version&gt;<br>    &lt;/dependency&gt;<br>&lt;/dependencies&gt;</pre><p>here is example how to use @EnableRuleMigrationSupport at class level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JSJxsLrFCYq2PXOsht0XQw.png" /></figure><p>what else? there are many features , but I am concluding here.</p><h4>References:</h4><p><a href="https://junit.org/junit5/docs/current/user-guide/">https://junit.org/junit5/docs/current/user-guide/</a></p><h4>About Me:</h4><p>This is <strong>Mahesh Oruganti</strong> working as Automation QA Engineer at <a href="https://www.dotdash.com/">dotDash.</a> I hope you enjoy this Article. Happy learning. Thanks!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f44a8611e5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up a Selenium Grid with Docker containers for Running Automation Tests]]></title>
            <link>https://techblog.people.inc/setting-up-a-selenium-grid-with-docker-containers-for-running-automation-tests-c43aceccd5d9?source=rss-4af4db048f23------2</link>
            <guid isPermaLink="false">https://medium.com/p/c43aceccd5d9</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[continuous-testing]]></category>
            <category><![CDATA[selenium-webdriver]]></category>
            <category><![CDATA[containerization]]></category>
            <category><![CDATA[automated-testing]]></category>
            <dc:creator><![CDATA[Mahesh Oruganti]]></dc:creator>
            <pubDate>Tue, 16 Apr 2019 14:48:04 GMT</pubDate>
            <atom:updated>2020-08-21T13:56:14.704Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setting up an on-demand Selenium Grid with containers</h3><blockquote>The objective of this post is to explain, how to set up or spin up chrome containers(selenium grid with chrome nodes containers) using docker containerization way to run Automation Tests.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*KZ9m6V8WS1WwzW03tODDOg.jpeg" /></figure><p><strong>Note:</strong> Note: if you are new to docker world, please go through a previous post (<a href="https://medium.com/@moruganti_33642/understanding-docker-basics-be35dc939949">docker-basics</a>) to understand the basics of docker.</p><h3><strong>What is Selenium Grid</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/1*V3hCRAfTNk_2UOuAnPjVWg.png" /><figcaption><strong>Selenium Grid</strong></figcaption></figure><blockquote><strong>Selenium Grid:</strong> Selenium Grid is a project created for executing tests on different browsers and operating systems. It has a simple architecture: A hub and one or more nodes. You run your test across the hub and hub distributes the test across different browsers.</blockquote><h4><strong>Advantages of Selenium Grid:</strong></h4><ul><li>Reduces execution time with distributed testing.</li><li>Allows cross-browser and platform testing</li></ul><h4><strong><em>Challenges of Selenium Grid:</em></strong></h4><ul><li>Hard to configure (Installing Java, downloading selenium standalone server, installing related browsers and drivers, etc.).</li><li>Hard to manage (testing different versions of different browsers).</li><li>Resource usage</li></ul><h3><strong>Docker Selenium</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3z9Z-gEr2HxVpNxsjBdLIA.png" /></figure><ul><li>It uses the same architecture but each component, hub, and nodes, is a separate container.</li><li>is highly used by test teams to run their tests in parallel on Selenium Grid</li></ul><h4><strong><em>What are the advantages of docker Selenium?</em></strong></h4><ul><li>We got rid of all the dependencies are mentioned above.</li><li>Does not use system resources like VM’s so it’s lightweight.</li><li>We can easily manage all the version complexity with docker registry.</li></ul><p>The break down of steps required to set up selenium grid using docker is as following.</p><h4>STEP 1 : Pull docker images for Selenium.</h4><p>As discussed in my previous blog, we need to pull Selenium docker images specific to chrome-debug from docker hub. Login to docker hub over here, <a href="https://hub.docker.com/">https://hub.docker.com/</a> and search for the below images and pull them into your computer/system. right now we have the below images available for chrome.</p><blockquote><strong>selenium/hub:</strong> Image for running a Grid Hub</blockquote><blockquote><strong>selenium/node-chrome-debug:</strong> Grid Node with Chrome installed and runs a VNC server, needs to be connected to a Grid Hub</blockquote><p><strong>Note: node-{Browser Name}</strong> and <strong>node-{Browser Name}-debug</strong> cannot be used alone; <strong>they must be connected to a hub</strong>. <strong>Debug versions include a VNC server</strong> to visually debug the browser during the test.</p><h4>Check Images in local file system:</h4><p>verify images exist pulled from docker hub by running command docker images. (make sure docker engine running in your computer).</p><blockquote><strong>Note: </strong>I have other images too in my system .Ignore other images showing up on below screenshot.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xLRYwe7B08Uvi7e9BTY69Q.png" /></figure><h4>STEP 2 : Configure Images and Run containers (hub, chrome).</h4><blockquote>We can start creating containers now that we have the images. You are able to run and start containers one at a time through the <strong>docker run</strong> command.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*etq26hBNTW-b63mH1yRCMQ.jpeg" /></figure><p>But we don’t want to create one container at a time!!. We’d rather create the containers and network them together in ONE command using docker compose and <strong>docker-compose.yml</strong> file<strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LSuO02HfaRG2ctAuwEZdSA.png" /></figure><p><strong>STEP 3 : Docker Compose and YML Overview:</strong></p><ul><li><strong>docker-compose</strong> is a tool for defining and running multi-container Docker applications. With Compose, you use a Compose file to configure your application’s services. Then, using a single command, you create and start all the services from your configuration.</li><li>You define a single yml file with the services you want and then use the single command to create all of it at once. here is the sample <strong>docker-compose.yml </strong>file.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*yyvi5g3xshYMGt1zQgoRGA.png" /><figcaption>Ex: <strong>docker-compose.yml file</strong></figcaption></figure><ul><li><strong>Version</strong>: “3” — as of this recording, this is the latest version of docker-compose files</li><li><strong>Services</strong> (or containers): — this is where we list the images we’ll be using and their configuration</li><li><strong>image</strong>: determine which container will be used to start container.</li><li><strong>ports: </strong>publish port with &lt;HOST:CONTAINER&gt; format.</li><li><strong>volumes: </strong>mount host path to service with &lt;HOST:CONTAINER&gt; format.</li><li><strong>depends_on</strong>: containers start according to dependency order. In our example chrome and firefox will start after hub starts</li><li><strong>environment</strong>: specifies environment variables. You can see other environment variables of selenium images by using docker image inspect &lt;IMAGE_ID&gt;</li></ul><blockquote><strong>Notes:</strong> We’re calling the first container “selenium-hub” and saying that:<br> It will use the selenium/hub image<br> It will expose a port at 4444 (we’ll use this later to connect to the grid)<br> It will allow 16 sessions or tests to run at one time<br> And we’ll set some grid timeouts to the recommended 300 seconds</blockquote><blockquote><strong>Notes:</strong> I added one Hub service and two chrome-debug node services. if you notice, the configuration(image, environment, volume, links, etc ..) for chrome-debug nodes is pretty much same except ports. so we can avoid repeated stuff over here by moving common configuration into another yml file and reference that file over here. so here is my final common.yml file and docker-compose.yml file looks like(added some extra useful configs but you can remove them as per your need).</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*Qlu4uVuFKLU4DCxcfbnd_w.png" /><figcaption><strong>common.yml</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*aB7Zy4S5ZZLONEVD0uHNBQ.png" /><figcaption><strong>docker-compose.yml</strong></figcaption></figure><blockquote><strong>Note:</strong> port numbers should be different for each chrome-debug service. update to version:”2&quot; if you see any issues.</blockquote><h4><strong>STEP 4 : </strong>Spin up Grid/Chrome Containers Using Docker Compose:</h4><blockquote>There are two different ways <strong>docker Compose </strong>available.</blockquote><ol><li>docker Compose comes by default with<strong> docker engine installation.</strong></li><li>download or Install it from <a href="https://github.com/docker/compose/releases/"><strong>https://github.com/docker/compose/releases/</strong></a></li></ol><p><strong>Note:</strong> if you are using mac/Linux you can run below command to install it from docker GitHub. update url with uname values (run uname -s and uname -m commands in your shell and copy paste values ). you can also change the version number(1.23.2) to latest if you want.</p><p><strong>sudo curl -L \”</strong><a href="https://github.com/docker/compose/releases/download/1.23.2/docker-compose-/$(uname"><strong>https://github.com/docker/compose/releases/download/1.23.2/docker-compose-\$(uname</strong></a><strong> -s)-\$(uname -m)\” -o /usr/local/bin/docker-compose</strong></p><p>Once the download is complete, apply executable permissions to the Compose binary.</p><p><strong>sudo chmod +x /usr/local/bin/docker-compose</strong></p><h4>To Uninstall docker Compose:</h4><p>sudo rm /usr/local/bin/docker-compose</p><p><strong>verify docker-compose installed:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*UzcrquPymP5L0SDZy8RWog.png" /><figcaption><strong>docker-compose</strong></figcaption></figure><blockquote>Once you install <strong>docker-compose</strong> you can directly run docker-compose.yml from the directory where the file exist , But you should have docker engine running in your computer.</blockquote><blockquote>you can also specify location of the docker-compose.yml file using -f flag.</blockquote><blockquote><strong>1) docker-compose up –d ( </strong>by default<strong> </strong>it looks for docker-compose.yml or docker-compose.yaml file in the current directory and run it. if not find, you will get below error message)</blockquote><blockquote><em>ERROR:</em></blockquote><blockquote><em>Can’t find a suitable configuration file in this directory or any</em></blockquote><blockquote><em>parent. Are you in the right directory?</em></blockquote><blockquote><em>Supported filenames: docker-compose.yml, docker-compose.yaml</em></blockquote><blockquote><strong>2) docker-compose -f docker-compose.yml up -d</strong></blockquote><blockquote><strong>3) docker-compose -f /root/home/test/docker-compose.yml up -d</strong></blockquote><blockquote><strong>Note:</strong> If you want to run your services in the background, you can pass the -d flag for “detached” mode. -f is for file.</blockquote><p>You would be able to see services up and running once you spin up services(hub, chrome nodes). you can run <strong>docker ps </strong>command for verifying.</p><blockquote><strong>Note:</strong> containers names starts with current working directory name by default( in this case it is <strong>docker_training</strong>). also we get create network bridge which is used for communicate from one containers/services to others.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YL3HjRTkbNAnQImL4OgXJQ.png" /><figcaption><strong>Image 1</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VuMTtGzV2MOdKLNKyRedbw.png" /><figcaption><strong>Image 2</strong></figcaption></figure><p><strong>Verify Hub and Nodes Are Up:</strong></p><p>Just go to <a href="http://localhost:4444/grid/console">http://localhost:4445/grid/console</a> and you would be able to see grid is up and running with two chrome debug nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_8bHJzsBP3-62UlnHkyURg.png" /></figure><p>Now you can run your automation tests using target remote grid(localhost:4445). We are not going to discuss about test creation and execution in this post.</p><h4><strong>Stop the Services/Containers:</strong></h4><blockquote>To stop the services you could run below command. it will stop the services and remove them.</blockquote><blockquote><strong>docker-compose -f docker-compose.yml down</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AQVzho85PC9iJXAfdh50yw.png" /><figcaption><strong>docker-compose.yml down</strong></figcaption></figure><h4><strong>STEP 5 : VNC to Containers.</strong></h4><p>Since we ran <strong>chrome-debug </strong>containers and which comes with vnc server, we could connect to vnc server and watch/debug Automation Tests. To login to vnc server,</p><ol><li>Get IP address of your machine/host (<strong>ifconfig -a </strong>if you are using Mac/Linux machines) where you spun up containers/services.</li><li>Create a file called view.sh and add the below source code. Run the <strong>view.sh</strong> in your command terminal and pass IP address of your host as input. It will bring up GUI of chrome containers just created. please refer below screen shot <strong>Containers</strong>. you can also use various ways to log into vnc server. (for example you can download vnc client and add server/port configs and login).</li><li>If you are Mac user and if you have installed “<strong>Connect to Server</strong>”, you can Vnc to server using IP Address and container Port numbers(in this case 9001, 9002)</li><li>Download View.sh source code from github <a href="https://github.com/MaheshOruganti/docker-selenium/blob/master/view.sh">https://github.com/MaheshOruganti/docker-selenium/blob/master/view.sh</a></li></ol><p><strong>vnc://&lt;IP Address of your host&gt;:&lt;container Port number&gt;</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VPWuvtZ3jm8UUcDS7r71zg.png" /><figcaption>View.sh</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c0dualmvpem4UBCxPIDpbQ.png" /><figcaption>Containers</figcaption></figure><blockquote><strong>Notes: </strong>The port numbers I added range from 9001 to 9002 because I have spin up only two chrome-debug nodes with two different port numbers (check docker-compose.yml file). but you can add more chrome-node services(up to 30) as per your requirements and update port numbers range over here.</blockquote><h4>STEP 6 : Login to container.</h4><blockquote>Use <strong>docker</strong> <strong>ps</strong> to get the name of the existing <strong>container</strong>.</blockquote><blockquote>Use the command <strong>docker</strong> exec -it &lt;<strong>container</strong> name&gt; /bin/bash to get a bash shell in the <strong>container</strong>.</blockquote><p>Voila we have a working selenium docker instance and chrome debug containers for running automation tests. If you want to spin up firefox/chrome containers, the process should be the same. Also you can spin up both firefox and chrome nodes with grid combination.</p><p>Using this approach we could save lot of time, cost effective, accurate test results.</p><blockquote>At Dotdash we run around 8000+ Automation Tests across multiple properties and we run regression tests multiple times everyday against the test infrastructure, where we have selenium grid connected to multiple grid nodes(AWS Ec2 instances). The huge increase in our regression tests mandate we scale our test infrastructure on demand. By using containerized selenium ,we end up running tests on few Jenkins slave machines (we run automated tests using Jenkins job). This allowed us to get rid of the fixed and difficult to scale test infrastructure and find efficiency as well as control the costs of running the AFT’s.</blockquote><h4>References:</h4><p><a href="https://github.com/SeleniumHQ/docker-selenium">SeleniumHQ/docker-selenium</a></p><p><a href="https://docs.docker.com/compose/reference/overview/">Overview of docker-compose</a></p><h4>About Me:</h4><p>This is <strong>Mahesh Oruganti</strong> working as Automation QA Engineer at <a href="https://www.dotdash.com/">dotDash.</a> I hope you enjoy this Article. Happy learning. Thanks!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c43aceccd5d9" width="1" height="1" alt=""><hr><p><a href="https://techblog.people.inc/setting-up-a-selenium-grid-with-docker-containers-for-running-automation-tests-c43aceccd5d9">Setting up a Selenium Grid with Docker containers for Running Automation Tests</a> was originally published in <a href="https://techblog.people.inc/">People Inc. Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Docker Basics]]></title>
            <link>https://techblog.people.inc/understanding-docker-basics-be35dc939949?source=rss-4af4db048f23------2</link>
            <guid isPermaLink="false">https://medium.com/p/be35dc939949</guid>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Mahesh Oruganti]]></dc:creator>
            <pubDate>Tue, 12 Mar 2019 14:14:50 GMT</pubDate>
            <atom:updated>2019-03-13T20:45:44.762Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>The objective of this post is to explain Docker Basics and usage of Docker commands.</blockquote><h3><strong>Intro to Docker</strong></h3><ul><li><strong>Docker</strong> is a platform for developers and sysadmins to develop, deploy, and run applications with <strong>containers.</strong></li><li>The use of Linux containers to deploy applications is called <strong>containerization</strong>.</li><li><strong>Containerization is increasingly popular because containers are:</strong></li></ul><blockquote><strong>Flexible: </strong>Even the most complex applications can be containerized<strong>.</strong></blockquote><blockquote><strong>Lightweight: </strong>Containers leverage and share the host kernel<strong>.</strong></blockquote><blockquote><strong>Interchangeable: </strong>You can deploy updates and upgrades on-the-fly<strong>.</strong></blockquote><blockquote><strong>Portable: </strong>You can build locally, deploy to the cloud, and run anywhere<strong>.</strong></blockquote><blockquote><strong>Scalable: </strong>You can increase and automatically distribute container replicas<strong>.</strong></blockquote><blockquote><strong>Stackable: </strong>You can stack services vertically and on-the-fly</blockquote><h3><strong>Containers and virtual machines</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Miznro8MHl4841lDSY8xUA.png" /></figure><p>A <strong>container</strong> runs <em>natively</em> on Linux and shares the kernel of the host machine with other containers. It runs a discrete process, taking no more memory than any other executable, making it lightweight.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h_NPeN-eF9WdaIlmymB_Og.png" /></figure><p>By contrast, a <strong>virtual machine</strong> (VM) runs a full-blown “guest” operating system with <em>virtual</em> access to host resources through a hypervisor. In general, VMs provide an environment with more resources than most applications need.</p><h3>What are <strong>Containers?</strong></h3><ul><li><strong>Containers</strong> are the building blocks of the containerization world and allow you to package only the things you need for your application or service without creating a whole operating system, like Virtual Machines.</li><li>They are faster and more lightweight.</li></ul><p>Containers also give you control over your environment because you can specify exactly what you want each container to look like by using blueprints called <strong>Images</strong></p><h3>What are Images?</h3><ul><li><strong>Images</strong> are the specs or details used to create containers.</li><li>Just like how images for VMs let you spin up a Windows instance of Vista or XP, or Linux images let you pick between Ubuntu, Debian, or other versions, images for Docker let you specify which services, libraries, or dependencies you need for a container</li></ul><h3>Services<strong> Without Docker:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*CCoEvdNxnj0cae4OBjODGw.png" /></figure><h3>Services <strong>With Docker:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*oNex915LdHMJk62L8X1ZFA.png" /></figure><h3><strong>Installing Docker</strong></h3><blockquote>Install docker engine from downloading from docker web site , <a href="https://docs.docker.com/docker-for-mac/install/">https://docs.docker.com/docker-for-mac/install/</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*15Ty1y8C6reEtUAqPEVSuA.png" /></figure><h3>Verify Docker Installation</h3><blockquote><em>After installation done, please verify that docker installed correctly by running </em><strong><em>docker version</em></strong><em> command on command line. You would be able to see output below mentioned.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*4hW773SqmjKrC-BCv8OkDw.png" /></figure><h3>Launch Docker Engine</h3><blockquote>Launch the docker Engine, and you would be able to see below screen on your desktop when you click on docker icon.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*DBi8iu4OL1x3UHcLZDe0NA.png" /></figure><h3><strong>Docker Account signup:</strong></h3><blockquote>You need to have sign up docker account to pull images from docker hub.</blockquote><ol><li>go to <a href="https://hub.docker.com/"><strong>https://hub.docker.com/</strong></a></li><li>signup or create account.</li></ol><h3>Pull Images from Docker:</h3><blockquote>Search for existing images in the docker hub/repository and pull images into your system using <strong>docker pull</strong> command . below is example to pull “<strong>dockersamples/static-site</strong>” image.</blockquote><p><strong>docker pull</strong> dockersamples/static-site</p><h3><strong>Docker Commands and it’s Usages:</strong></h3><h4>List images:</h4><blockquote>docker image ls</blockquote><h4>$ docker images ls</h4><p>dockersamples/static-site latest f589ccde7957 2 years ago 191MB</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MRiZNsP2o0eV5WK1XgBNrg.png" /></figure><h3><strong>Run a command in a new container</strong></h3><blockquote>docker run</blockquote><p>docker run dockersamples/static-site</p><h3>List containers:</h3><blockquote>docker ps</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tnqmrREysMfjY5LwKKsL9Q.png" /></figure><h3><strong>Display a live stream of container(s) resource usage statistics</strong></h3><blockquote>docker stats</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PeT4yNwYVanwXcVpYdacsg.png" /></figure><h4>Some of the useful commands :</h4><blockquote><strong>docker stop &lt;CONTAINER_ID&gt; : </strong>Stops container.</blockquote><blockquote><strong>docker stats : </strong>used to observe CPU, memory usage of containers.</blockquote><blockquote><strong>docker inspect &lt;IMAGE&gt; </strong>: gives more details about images.</blockquote><blockquote><strong>docker run -it &lt;Container&gt; /bin/sh </strong>: Running the run command with the -it flags attaches us to an interactive tty in the container. Now you can run as many commands in the container as you want</blockquote><blockquote><strong>docker rm</strong> &lt;<strong> Container_ID&gt; : </strong>removes container</blockquote><blockquote><strong>docker run</strong> –help</blockquote><blockquote><strong>docker build : </strong>Build the image</blockquote><blockquote><strong>docker push </strong>: Push your image to <a href="https://cloud.docker.com/">Docker Cloud</a></blockquote><blockquote><strong>List Docker containers</strong> (running, all, all in quiet mode)</blockquote><blockquote><strong>docker container</strong> ls</blockquote><blockquote><strong>docker container</strong> ls — all</blockquote><blockquote><strong>docker container</strong> ls –aq</blockquote><blockquote><strong>Docker Networking: (Usage: docker network COMMAND)</strong></blockquote><blockquote><strong>docker network</strong></blockquote><blockquote><strong>docker network ls</strong></blockquote><blockquote><strong>docker network inspec</strong></blockquote><blockquote><strong>docker info</strong></blockquote><h3><strong>Docker Compose and YML Overview</strong></h3><ul><li><strong>docker-compose</strong> is a tool for defining and running multi-container Docker applications. With Compose, you use a Compose file to configure your application’s services. Then, using a single command, you create and start all the services from your configuration</li><li>You define a single yml file with the services you want and then use the following command to create all of it at once.</li></ul><blockquote><strong>docker-compose up –d</strong></blockquote><blockquote><strong>docker-compose -f docker-compose.yml up -d</strong></blockquote><blockquote><strong>Note: </strong>If you want to run your services in the background, you can pass the -d flag (for “detached” mode)</blockquote><blockquote><strong>docker-compose -f docker-compose.yml down (to stop the services)</strong></blockquote><p>Below is the example of docker-compose.yml.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*HI3_qMflTYS4lr7kU6QXwQ.png" /><figcaption>docker-compose.yml</figcaption></figure><ul><li><strong>Version</strong>: “3” — as of this recording, this is the latest version of docker-compose files</li><li><strong>Services</strong> (or containers): — this is where we list the images we’ll be using and their configuration</li><li><strong>volumes: </strong>mount host path to service with &lt;HOST:CONTAINER&gt; format.</li><li><strong>ports: </strong>publish port with &lt;HOST:CONTAINER&gt; format.</li><li><strong>image</strong>: determine which container will be used to start container.</li></ul><h4><strong>References:</strong></h4><blockquote><a href="https://docs.docker.com/engine/reference/commandline/docker/">https://docs.docker.com/engine/reference/commandline/docker/</a></blockquote><blockquote><a href="https://docs.docker.com/compose/overview/">https://docs.docker.com/compose/overview/</a></blockquote><h4>About Me</h4><p>This is Mahesh Oruganti working as QA Automation Engineer at Dotdash. Happy Learning. Thanks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be35dc939949" width="1" height="1" alt=""><hr><p><a href="https://techblog.people.inc/understanding-docker-basics-be35dc939949">Understanding Docker Basics</a> was originally published in <a href="https://techblog.people.inc/">People Inc. Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Build Slack Bot with Python]]></title>
            <link>https://techblog.people.inc/how-to-build-slack-bot-with-python-1cfe86302672?source=rss-4af4db048f23------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cfe86302672</guid>
            <category><![CDATA[slack]]></category>
            <dc:creator><![CDATA[Mahesh Oruganti]]></dc:creator>
            <pubDate>Tue, 12 Mar 2019 14:13:38 GMT</pubDate>
            <atom:updated>2019-10-11T14:13:41.628Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Bots are a useful way to interact with chat services such as <a href="https://slack.com/">Slack</a>. If you have never built a bot before, this post provides an easy starter tutorial for combining the <a href="https://api.slack.com/">Slack API</a> with Python to create your first bot. <strong>here I am going to explain an example of how to interact(run) Jenkins jobs from slack using slack bot</strong>.</blockquote><h3><strong>What is Bot/slackbot:</strong></h3><ul><li>Bots are handy little assistants that hang out in your app, wait for commands, and then find or create the things you need</li><li>A bot is a type of Slack App designed to interact with users via conversation.</li><li>A bot is the same as a regular app: it can access the same range of APIs and do all of the magical things that a Slack App can do.</li></ul><h3><strong>What Do you Need to Build a Bot?</strong></h3><p>Ex: Slack(A place to type your text) , Bot(to read your text) , python server which interacts with Jenkins (to do something)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*yIF0PqyaaM02OxkRpsnLXw.png" /></figure><h3>Tools We Need</h3><ul><li>Either Python 2 or 3</li><li><a href="https://pip.pypa.io/en/stable/">pip</a> and <a href="https://virtualenv.pypa.io/en/stable/">virtualenv</a> to handle Python application dependencies</li><li>Slack Account (install if you don’t have one or use if your team or organization has already one)</li><li>you can refer slack api docs over here (<a href="https://api.slack.com/">https://api.slack.com/</a>)</li><li>Install Jenkins if you don’t have one.(refer <a href="https://jenkins.io/doc/book/installing/">https://jenkins.io/doc/book/installing/</a></li><li><a href="https://linuxize.com/post/how-to-install-jenkins-on-centos-7/">https://linuxize.com/post/how-to-install-jenkins-on-centos-7/</a>)</li></ul><p>I think most of the organizations have slack, jenkins to automate CI/CD processes.</p><h3>Creating Custom Bot :</h3><p><strong>Create a Bot and Setup integration</strong></p><p><strong>Notes</strong>: Assuming you already installed slack. go to your slack settings and create custom bot. below is the screen shot for reference(there are many ways creating custom slack bot). add the bot name(ex: jenkins-bot)and click <strong>Add bot integration</strong> button and add all other below required details. keep note that Api token is confidential and don’t share it it anyone.we are going to use that API token value to connect slack API’s.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w3LV58wCqMGGVFL-0xSJeQ.png" /></figure><ul><li><strong>API Token </strong>: The library you are using will want an API token for your bot.(Be careful when sharing bot user tokens with applications. Do not publish bot user tokens in public code repositories.)</li><li><strong>Customize Name</strong>: Choose the username for this bot.</li><li><strong>Customize Icon</strong>: Change the icon used for this bot.</li><li><strong>Full Name</strong>: You can choose to display your bot’s full name rather than its username.</li><li><strong>What this bot does</strong>: Let others on your team know what this bot is used for (optional).</li><li><strong>Channels</strong>: This bot is currently in the following channels.(please create one slack channel in your installed slack if you don’t have any)</li></ul><h3>Setting up Local Environment</h3><p><strong>Note:</strong> if you are on Mac, Linux, open terminal and go to your home directory or any working directory you like and run below commands.</p><pre>virtualenv slcakbot<br>source slackbot/bin/activate<br>pip install slackclient</pre><p><strong>All the files and required code provided below</strong>, <strong>you can keep all methods in one file(slackbot.py) as well ( it’s up to you).</strong></p><h3>Download source code from gitHub</h3><blockquote>please download source code over here and make changes as per your needs. <a href="https://github.com/MaheshOruganti/Slackbot">https://github.com/MaheshOruganti/Slackbot</a></blockquote><ol><li><strong>bot.py ( which is base class)</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W4J9jI8ShNGSCAxpmlgixg.png" /></figure><p><strong>2) slackbot.py</strong> (create file and add all the below code into )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TBDcvNFLO8_fqn6lhe2Kzg.png" /></figure><h3><strong>Slack API Methods used</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xFj1djmpQ8AngmIu57Y4ug.png" /></figure><p><strong>SlackClient(<em>token</em>) :</strong></p><p>The Slack Client makes API Calls to the Slack Web API as well as managing connections to the <a href="https://api.slack.com/rtm">Real-time Messaging API via websocket</a></p><ul><li>It also manages some of the Client state for Channels that the associated token (User or Bot) is associated with.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e1gLvT55LAIRNm6YYM1enA.png" /></figure><p><strong>rtm_connect():</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0ooskLp3yyqvbSsBIc7qKw.png" /></figure><ul><li>Connects to the RTM WebSocket</li></ul><p><strong>rtm_read():</strong></p><ul><li>Reads from the RTM WebSocket stream then calls <em>self.process_changes(item)</em> for each line in the returned data.</li><li>Multiple events may be returned, always returns a list [], which is empty if there are no incoming messages.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o0vzwlzrZxjR6odCI-IztA.png" /></figure><p><strong>api_call(<em>method</em>, <em>**kwargs</em>): </strong>Call the Slack Web API</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PHuLj6O9_8KESUGNqUwBHQ.png" /></figure><p>Ex: self.slack_client.api_call(“chat.postMessage”, channel=self.channel, text=message, as_user=True)</p><p><strong>Notes:</strong></p><blockquote>1)please go through python documents , slack API docs to understand each imports used in this file.</blockquote><blockquote>2)I commented out Bot token here, please use your slack api token which you got when you create custom bot the above mentioned.</blockquote><blockquote>3) bot id you will get once you run the program..please update that later.</blockquote><blockquote>4) please make sure all lines of code added in this slackbot.py file.</blockquote><p>3) <strong>user-info.py ( to get user info)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7NKyBEGDREoTBUw0K5mF9A.png" /></figure><p>4. <strong>JenkinsJobCommands.py (</strong>this file has actual method to run/trigger jenkins job.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f_oaFOaHyPRSelyax9g6ow.png" /></figure><blockquote><strong>Notes: </strong>here you need to get headers(authorization, jenkins-crumb ): construct it from your jenkins user credentials you are going to use for triggering your jobs. ask Devops people to get these details. you can also keep this method in slackbot.py and call it.</blockquote><blockquote>Search in google how to create authorization key using jenkins credentials(userID, password).</blockquote><blockquote>please post me if you don’t find.I can help on that.</blockquote><p><strong>example to build url for job with parameters:</strong></p><h4>url = “&lt;jenkins job url path&gt;/buildWithParameters&quot; + \<br> “?PROJECT=” + self.projectName + “&amp;ENV=” + self.env + “&amp;DEVICE=” + device + “&amp;TEST=” + self.test+ “”</h4><p>1)parse chat data/slack command from slackbot and keep values in variables(self.projectName ,self.env ,self.test etc..).</p><p>2) send the variable values to jenkins job parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*-iWupn293bes2IJYchADYA.png" /></figure><h3><strong>Running slackbot:</strong></h3><p>Now that all of our code is in place we can run our SlackBot on the command line with the python slackbot.py command.</p><h4>Important Notes:</h4><p>Source code available</p><blockquote>1.check the console logs, that slackbot started and up and running .</blockquote><blockquote>2. check your Bot(jenkins-bot) is active in your slack. if you dont’ see slackbot in your slack, please invite it into slack(just type @jenkins-bot and invite). you can also invite in to slack channels/groups.</blockquote><blockquote>3. Run the commands from the jenkins-bot. command should start with “jenkins” . you can change the command whatever you like but you need to update that in your slackbot.py</blockquote><blockquote>4. understand that what code is doing, and probably you need to handle/add logic that what command you need to pass to slackbot to run the jenkins job.</blockquote><blockquote>5. if your jenkins job expecting parameters (Ex: project name , type of device, type of tests) here is the commands I use from the slack , ( <a href="http://twitter.com/venus"><strong>@j</strong></a><strong>enkins-bot jenkins &lt;test-project&gt; &lt;mobile&gt; &lt;SmokeTests&gt;</strong>).</blockquote><blockquote><a href="http://twitter.com/venus"><strong>@j</strong></a><strong>enkins-bot help</strong></blockquote><blockquote>6. <strong>This slackbot can also use for handling multiple jenkins jobs, also can use different purposes (Ex: building projects from gitHub etc..) (not only handling jenkins jobs)</strong></blockquote><blockquote>7. you can build and deploy this code on any environment where it runs as a server. but you need setup.py file(you can google it , how to create setup.py)</blockquote><blockquote>8. I did not explain that what each method perform separately, but all the methods has method descriptions. please read it understand.</blockquote><p>I know this is crazy :) :) . <strong>but this type of bots useful to trigger jenkins jobs from your mobile if you have slack app installed(you don’t have to be in office/office network)</strong>. I hope you guys understand . please try and understand the logic before making any changes. please also look for other posts online to build slack bots.</p><h4>About Me:</h4><p>This is Mahesh Oruganti working as an Automation QA Engineer at Dotdash(<a href="https://www.dotdash.com/">https://www.dotdash.com/</a>) . Happy learning . Thanks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cfe86302672" width="1" height="1" alt=""><hr><p><a href="https://techblog.people.inc/how-to-build-slack-bot-with-python-1cfe86302672">How to Build Slack Bot with Python</a> was originally published in <a href="https://techblog.people.inc/">People Inc. Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automated Visual Testing using aShot and Selenium Webdriver]]></title>
            <link>https://techblog.people.inc/automated-visual-testing-using-ashot-and-selenium-webdriver-e1da268b74c8?source=rss-4af4db048f23------2</link>
            <guid isPermaLink="false">https://medium.com/p/e1da268b74c8</guid>
            <category><![CDATA[visual-regression]]></category>
            <category><![CDATA[automates-visual-testing]]></category>
            <category><![CDATA[screenshot-comparison]]></category>
            <dc:creator><![CDATA[Mahesh Oruganti]]></dc:creator>
            <pubDate>Tue, 12 Mar 2019 14:12:01 GMT</pubDate>
            <atom:updated>2019-10-11T14:11:27.877Z</atom:updated>
            <content:encoded><![CDATA[<h3>Automated Visual Testing using aShot and Selenium Web driver</h3><blockquote>The objective of this post is to explain how to add Automation visual testing for existing selenium, Java based automation test framework. Let’s talk about the experience, challenges we faced while setting up automated visual testing at dotDash(<a href="https://www.dotdash.com/">https://www.dotdash.com/</a>)</blockquote><p>Software engineering teams who are used to frequent deployments of their features tend to build tools that help them mitigate the test efforts for such a high turn around in deployments.At Dotdash we use a combination of functional tests,HTML scraping and Visual regression tests to reduce the amount of time spent on regression testing.Functional tests focus on the features that are being developed while the HTML scraping focus on configuration settings etc and Visual tests help us detect design issues before we deploy code changes to production.</p><h3>BENEFITS OF VISUAL TESTS?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w6WzOtf-5mK39FUh5DVkbw.jpeg" /><figcaption>Image Courtesy :</figcaption></figure><p>We shipped lot of design bugs to production which prompted us to search for a solution that will help us detect them in our QA pipeline.These are examples of visual design changes that we tend to leak to production prior to the addition of visual tests to our tool set :</p><ul><li>Minute pixel changes to logos, font size,SVG and design elements which are hard to find during manual testing phase.</li><li>It is manually intensive to cover all the test matrix regularly for frequent releases.</li><li>Testing on various web browsers, Devices, Operating systems , Screen resolutions and Responsive design.</li></ul><p>Here is the list of tools/technologies we used for visual testing(it forms the foundation for functional testing at dotdash as well):<strong><em>Selenium WebDriver, Selenium Grid,Java 8, Junit 4, Jenkins, aShot.</em></strong></p><p>Venus(our in house web application test framework) is designed and developed using page object model. All our functional tests are executed on remote grid nodes. We trigger different categories of functional tests(smoke , regression, visual tests) by leveraging parametrized Jenkins jobs.</p><h4>CHALLENGES</h4><ul><li><strong>Handling multiple screenshots : </strong>We need to scroll till end of the page and take screenshots to make sure all of the page elements are captured.Not all of the browsers supported full page automated screenshots.</li><li><strong>Data changes and ad sizes: </strong>We started running visual tests in QA environment by baselining against Prod environment.Soon we found out the many of our data driven components were producing false positives, similarly Ads rendered on QA environments were different than Prod as well. So we end up with more tests failures.</li><li><strong>Scrollbar and Mouse : </strong>While taking screen shots of the web pages we should hide Scrollbar and Mouse to make sure they don’t interfere with automated comparisons.</li></ul><h4>How It Works?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*tGVI9PwrJP3Ixg3-18HGOQ.png" /></figure><h3>About aShot (<a href="https://github.com/pazone/ashot">https://github.com/pazone/ashot</a>)</h3><p><strong>WebDriver Screenshot utility</strong></p><ul><li>Takes a screenshot of a WebElement on different platforms (i.e. desktop browsers, iOS Simulator Mobile Safari, Android Emulator Browser)</li><li>Decorate screenshots</li><li>Provides flexible screenshot comparison</li></ul><h4>Basic Framework code</h4><blockquote>We need to have the below setup before running tests to import the ashot relevant classes to your existing framework.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*AO4g9_lyBlkco6ZZDUgLjQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Tj-cagmTf1g1JlJY63jHig.png" /></figure><h4>Test code</h4><p>The actual tests looks like below, we support multiple devices(PC, mobile_chromeEmulator, iPad) and we run tests on Chrome browser.We can hide or delete some web elements/components(css selectors) from the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*qKs7g1McKu4S20RvuPfi4w.png" /></figure><h4>Test Methods</h4><blockquote><strong>Note: </strong><em>All these methods are part of Runner class in the Interface commonTestMethods.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Ve4kkdmCdlrUN7rwGfwZ7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*KZQiEE5RLfvsb6RLFEd2mg.png" /></figure><h4>REPORT DIFFERENCES</h4><blockquote>Here are some examples of screen shot differences after running tests.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*gh-D0RimKJ89ZV7QSO-wTA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*CIb9s4YXf6-eAyzGBhtcVQ.png" /></figure><blockquote><strong>Notes: </strong>we run tests on selenium Grid and we trigger jobs through jenkins and upload Junit tests reports/screen shots to AWS s3 bucket, so that we can see test reports anytime.</blockquote><h4>Feature Enhancements</h4><ul><li>Run on multiple qa environments</li><li>Support multiple browsers.</li><li>Add element level validation.</li></ul><h4>About Me:</h4><p>This is Mahesh Oruganti, working as Automation QA Engineer at Dotdash. Happy Learning. Thanks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1da268b74c8" width="1" height="1" alt=""><hr><p><a href="https://techblog.people.inc/automated-visual-testing-using-ashot-and-selenium-webdriver-e1da268b74c8">Automated Visual Testing using aShot and Selenium Webdriver</a> was originally published in <a href="https://techblog.people.inc/">People Inc. Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>