<?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 Kishan Enjapuri on Medium]]></title>
        <description><![CDATA[Stories by Kishan Enjapuri on Medium]]></description>
        <link>https://medium.com/@kishansk26?source=rss-1dadcd3b204c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*71hVrvVRs-4q6PF_qt55Sg.jpeg</url>
            <title>Stories by Kishan Enjapuri on Medium</title>
            <link>https://medium.com/@kishansk26?source=rss-1dadcd3b204c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 20:51:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kishansk26/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[Testing AI Agents Beyond the Final Answer]]></title>
            <link>https://medium.com/@kishansk26/testing-ai-agents-beyond-the-final-answer-4f01f4421acd?source=rss-1dadcd3b204c------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f01f4421acd</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[load-testing]]></category>
            <category><![CDATA[ai-agent-testing]]></category>
            <dc:creator><![CDATA[Kishan Enjapuri]]></dc:creator>
            <pubDate>Sat, 07 Nov 2026 13:18:07 GMT</pubDate>
            <atom:updated>2026-11-07T13:20:08.152Z</atom:updated>
            <content:encoded><![CDATA[<h3>A practical framework for load testing, tool-trace validation, grounded responses, and behavioural regression</h3><p>Traditional software testing asks a relatively simple question: given an input, did the system return the expected output?</p><p>AI agents make that question much harder.</p><p>An agent may produce a convincing final answer while calling the wrong tool, passing an incorrect identifier, skipping an authorization check, inventing a percentage, or performing a write before the user confirms it. Conversely, an agent may produce a different, but still correct, sentence on every run.</p><p>This means testing only the final response is not enough. We need to test the <strong>path the agent took</strong>, the <strong>evidence behind its answer</strong>, and the <strong>business outcome it produced</strong>.</p><p>That is the problem I explored while building an agent load and behavioural regression framework in Python.</p><h3>The gap in conventional API testing</h3><p>A normal API test might assert:</p><pre>Input:  &quot;Show me my open tasks&quot;<br>Output: contains a list of tasks<br>Status: 200</pre><p>That verifies the surface result, but not the behaviour behind it.</p><p>Consider these two executions:</p><h3>Execution A</h3><pre>1. Call the task-list tool with status=OPEN<br>2. Receive the user&#39;s current tasks<br>3. Present titles from the tool response</pre><h3>Execution B</h3><pre>1. Skip the task-list tool<br>2. Reuse stale conversation memory<br>3. Invent a plausible list</pre><p>Both could return fluent, believable text. Only one is correct.</p><p>For write operations, the risk is larger. Suppose the user says:</p><blockquote><em>“Set the task progress to 75%.”</em></blockquote><p>A safe agent might first present the proposed update and wait for confirmation. A regressed agent might immediately invoke the update tool. If we inspect only the final wording, both may appear successful.</p><p>The framework therefore treats the agent’s <strong>tool trajectory</strong> as part of its contract.</p><h3>What the framework tests</h3><p>The framework combines two related capabilities:</p><ol><li><strong>Agent load testing:</strong> how the system behaves as concurrency increases.</li><li><strong>Behavioural regression testing:</strong> whether the agent still follows its expected decision and tool-use contract.</li></ol><h3>1. Tool-trace validation</h3><p>For each scenario, the framework captures observable events such as:</p><ul><li>tool name</li><li>tool arguments</li><li>tool result</li><li>execution order</li><li>failed tool calls</li><li>final response</li><li>conversation and context identifiers</li><li>transport and platform errors</li></ul><p>A scenario can then express an expected trace:</p><pre>expected_trace:<br>  order: strict<br>  steps:<br>    - tool: list_tasks<br>      args:<br>        status: ACTIVE<br>    - tool: get_task_details<br>      args:<br>        taskId: &lt;ID&gt;</pre><p>This catches regressions such as:</p><ul><li>the wrong tool was selected</li><li>a required call was skipped</li><li>an extra call appeared</li><li>arguments changed type or value</li><li>tools ran in the wrong order</li><li>a write happened before confirmation</li></ul><p>Dynamic values can be represented by placeholders such as &lt;ID&gt;, &lt;UUID&gt;, &lt;TIMESTAMP&gt;, &lt;NUMBER&gt;, bounded integer ranges, regular expressions, or one-of choices.</p><h3>2. Business-outcome validation</h3><p>A correct-looking trace does not guarantee a correct result.</p><p>A write tool could be called with the right arguments but return a failure. The agent could then incorrectly tell the user that the update succeeded.</p><p>The framework builds a structured outcome document from the observed execution and can assert facts such as:</p><pre>business_outcome:<br>  status: SUCCESS<br>  write_performed: true<br>  tools_failed: false</pre><p>It can also inspect paths inside tool results instead of trusting the agent’s narration.</p><h3>3. Grounding checks</h3><p>The framework verifies that important claims in the response are grounded in observable evidence.</p><p>For example, if an agent says:</p><blockquote><em>“Your task is now 75% complete.”</em></blockquote><p>then 75 should exist in the user’s request, a tool argument, or a tool result. If the available data contains 40 but the response states 75%, the framework reports an ungrounded number.</p><p>Grounding checks can validate:</p><ul><li>required facts from tool responses</li><li>forbidden facts or confidential names</li><li>percentages and other numerical claims</li><li>accidental disclosure of internal tool or API names</li></ul><p>This is especially valuable because hallucinations are often expressed in perfectly fluent language.</p><h3>4. Response-envelope and format validation</h3><p>Many production agents return structured UI blocks rather than plain text. A response may need to be valid JSON, NDJSON, or a custom envelope consumed by a frontend.</p><p>The framework can detect:</p><ul><li>missing envelopes</li><li>malformed structured output</li><li>empty responses</li><li>truncated platform payloads</li><li>prose inserted around machine-readable output</li></ul><h3>5. Optional semantic evaluation</h3><p>Some qualities cannot be captured completely with deterministic assertions:</p><ul><li>Was the refusal appropriate?</li><li>Was the answer complete?</li><li>Did it follow the instruction naturally?</li><li>Was the selected tool semantically suitable?</li><li>Was the answer consistent with the conversation?</li></ul><p>For these cases, the framework can add an LLM judge as a <strong>secondary evaluation layer</strong>.</p><p>The important design decision is that deterministic checks remain primary. A judge outage does not silently turn into a pass, and an unavailable judge does not hide tool, grounding, or business-outcome failures. Judge calls can also be capped to control cost.</p><h3>6. Load and latency analysis</h3><p>The same framework can run controlled concurrency sweeps and report:</p><ul><li>end-to-end latency percentiles</li><li>throughput</li><li>error rates</li><li>time to first token, when available</li><li>model, tool, and orchestration time decomposition</li><li>per-tool latency</li><li>token usage and estimated cost</li><li>concurrency saturation or queueing knees</li><li>SLO gate results</li></ul><p>This matters because a slow agent is not necessarily a slow model. The delay may come from a downstream business API, tool retries, orchestration overhead, or queueing inside the platform.</p><h3>Example: testing a safe progress update</h3><p>A behavioural suite can model a multi-turn workflow:</p><pre>User:  “My migration task is halfway.”<br>Agent: resolves the task and interprets the progress<br>Agent: asks the user to confirm the proposed percentage<br>User:  “Save it.”<br>Agent: invokes the update tool once<br>Agent: reports the actual result</pre><p>Useful assertions include:</p><ul><li>the task is resolved from real data rather than an invented ID</li><li>no update tool is called during the first turn</li><li>the confirmation contains the proposed value</li><li>the final write uses exactly the confirmed value</li><li>the write result indicates success</li><li>the response does not claim success if the tool failed</li></ul><p>A regression can then be injected deliberately, for example by changing the update value, skipping confirmation, adding an unexpected call, or returning an ungrounded percentage, to demonstrate that the harness catches each failure class.</p><h3>Error versus regression</h3><p>One lesson from building the framework was the importance of separating an environmental error from an agent regression.</p><p>If authentication expires, a network request times out, or a dependency returns an invalid response, the harness reports an <strong>error</strong>. It does not label the agent’s behaviour as wrong when the system never completed the turn.</p><p>A <strong>failure</strong> means the execution completed far enough to evaluate the contract and violated it: wrong tool, missing call, unsafe write, incorrect argument, ungrounded claim, invalid outcome, or similar behaviour.</p><p>This distinction makes reports actionable. Platform teams investigate transport errors; agent teams investigate behavioural failures.</p><h3>Real-world challenges uncovered by the framework</h3><p>Running the harness against real systems exposed issues that mock testing alone cannot reveal:</p><ul><li>the same tool succeeded when called directly but failed when called through the agent path</li><li>different versions of an agent endpoint behaved differently</li><li>a legitimate task title triggered an input guardrail</li><li>an agent selected the correct tools, but downstream authorization failed</li><li>a service returned success at the transport level while individual tools failed</li></ul><p>These are useful outcomes even when a suite is not green. A good test framework does not merely confirm that software works; it helps locate the boundary where it stops working.</p><p>The framework records the endpoint, agent identity, profile, scenario selection, concurrency, enabled evaluation layers, and the names (not values) of relevant context headers. This provides reproducible evidence without storing credentials.</p><h3>Designing trustworthy behavioural suites</h3><p>A few principles emerged from this work.</p><h3>Prefer observable contracts</h3><p>Assert tool calls, arguments, results, writes, and grounded facts. Avoid requiring one exact sentence when several answers would be correct.</p><h3>Keep deterministic checks primary</h3><p>Use an LLM judge for nuance, not for facts that code can verify exactly.</p><h3>Never normalize away business data</h3><p>Runtime-generated UUIDs and timestamps may need normalization. Task IDs, percentages, dates, and target values usually should not. Over-normalization can turn a real regression into a pass.</p><h3>Test negative behaviour explicitly</h3><p>“No tool call” and “no write occurred” are meaningful assertions. Greeting, off-topic, prompt-injection, and pre-confirmation scenarios are often some of the most valuable tests.</p><h3>Preserve evidence</h3><p>Reports should show the expected trace, observed trace, argument differences, tool failures, outcome evidence, and grounding source. A red result without an explanation is not useful.</p><h3>Treat credentials as runtime inputs</h3><p>Tokens and secrets should come from environment variables or a secure store, never from scenario files or reports. Reports should record only whether required authentication or context was present, not its value.</p><h3>Where this can go next</h3><p>The framework is already useful for agent development, QA, CI regression gates, and performance investigation. Natural next steps include:</p><ul><li>direct MCP contract tests that detect registry and OpenAPI drift</li><li>guardrail false-positive benchmark suites</li><li>schema validation for structured UI blocks</li><li>CI baselines and trend reporting across agent versions</li><li>replaying sanitized production traces as regression scenarios</li><li>comparing models against the same deterministic behavioural contract</li><li>environment-specific calibration without weakening shared expectations</li></ul><p>The larger idea is simple:</p><blockquote><em>An AI agent should be tested as a decision-making system, not only as a text generator.</em></blockquote><p>The final answer matters. But so do the tools it selected, the arguments it sent, the evidence it used, the writes it performed, the errors it encountered, and the outcome the user actually received.</p><p>That is the level at which agent testing becomes engineering rather than prompt experimentation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f01f4421acd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Real Time Selenium Reports using Grafana & InfluxDB]]></title>
            <link>https://medium.com/@kishansk26/real-time-selenium-reports-using-grafana-influxdb-4606ad80781c?source=rss-1dadcd3b204c------2</link>
            <guid isPermaLink="false">https://medium.com/p/4606ad80781c</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[selenium]]></category>
            <category><![CDATA[influxdb]]></category>
            <category><![CDATA[grafana]]></category>
            <dc:creator><![CDATA[Kishan Enjapuri]]></dc:creator>
            <pubDate>Sun, 17 May 2020 13:21:39 GMT</pubDate>
            <atom:updated>2020-05-17T13:21:39.440Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>Need for RealTime Reports?</strong></h4><p>There are many reporting tools and frameworks for Selenium but most of them are OFFLINE means test results are visible only when the test execution gets ended.</p><p>Let’s say we have around 500 Test cases in our regression suite in the build pipeline.What if there is a series of tests failing among the 500 tests because of some issue in environment configuration.We have to wait for the reports to find out what went wrong .Otherwise, you might need to look into jenkins console for the test execution results log to see the progress. It might be annoying in certain cases.</p><p>To solve this issue, we are going to learn about how to create real time reports using Influxdb and Grafana.</p><h4>What is InfluxDB?</h4><p><a href="https://www.influxdata.com/"><em>InfluxDB</em></a> is an open-source time-series database developed by InfluxData.</p><h4>InfluxDB Installation(Docker) &amp; Configuration (Windows)</h4><p>For installation of InfluxDB, Docker and Docker Compose should be installed on the host machine where it will run.Docker installation is covered at the <a href="https://docs.docker.com/engine/installation/"><strong>Docker website</strong></a>.Docker Compose installation is also covered at the <a href="https://docs.docker.com/compose/install/"><strong>Docker website</strong></a>.</p><p>Run the below docker command to run an instance of InfluxDB .</p><pre>docker run -p 8086:8086 -v ${PWD}:/var/lib/influxdb influxdb</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2DX9NNSzPfgmGG-7QYCgeQ.png" /><figcaption>We have successfully intialised influxdb</figcaption></figure><p>We need a database for logging the Test results . Open cmd and type the query to create a database.</p><pre>curl -i -XPOST http://localhost:8086/query --data-urlencode &quot;q=CREATE DATABASE selenium&quot;</pre><p>In this query we have created db schema named “selenium”</p><p>Next we will set up Grafana.</p><h4><strong>What is Grafana?</strong></h4><p><a href="https://grafana.com/"><em>Grafana</em></a> is an open-source metric analytics &amp; visualization suite.</p><h4>Grafana Installation(Docker) &amp; Configuration (Windows)</h4><p>Run the below docker command to run an instance of Grafana.</p><pre>docker run -d -p 3000:3000<br>  --name=grafana \<br>  -e &quot;GF_INSTALL_PLUGINS=grafana-piechart-panel&quot; \<br>  -v $PWD:/var/lib/grafana \<br>  grafana/grafana</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*5QtRAxTUfJdbrep2rfWvrA.png" /><figcaption>We have successfully intialised Grafana</figcaption></figure><p>Now, let’s launch the Grafana Dashboard. Go to any browser and launch this URL: <a href="http://localhost:3000/">http://localhost:3000</a></p><p><em>Username: admin &amp; Password: admin</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*G0yLXxr540wn0Ttn.png" /></figure><h4><strong>Adding Data Source (Influxdb) in Grafana</strong></h4><p>Go to Settings -&gt; Data sources -&gt; Add new data source as given here. Click on ‘Save &amp; Test’ button to ensure that Grafana is able to talk to InfluxDB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*-Mj3dcbhW_TMUTSUWL1gRw.png" /><figcaption>DataSource is added to Grafana</figcaption></figure><h4><strong>Configure Charts in Grafana</strong></h4><p>Click on Create Dashboard -&gt; Click on Add Query.</p><p>Create a Graph and configure the query as below:</p><p><strong>For Test Case Execution Time Point Graph:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t0MSP7t5SUcrEQnXYJoudw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WfSKOz5qNYj3FpSCUzGjXA.png" /></figure><p><strong>Test Results Count Pie-Chart :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hGbv3ho7KB4mG09SIObzxQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*or2faDrcW4ehmZ6jpHd_pQ.png" /></figure><p>And Save the Dashboard and select the Auto- refresh rate .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_7_RKHCv0BlHbESzK4lKDg.png" /><figcaption>Dashboard will look like this</figcaption></figure><p><strong>Now we will create a simple Maven project .</strong></p><p>Create a simple Test class:</p><pre>public class InfluxGrafanaTests {</pre><pre>@Test(description = &quot;Login&quot;)<br> public void launchApp() throws Exception {<br>  Thread.sleep(10000);<br>  Assert.fail();</pre><pre>}</pre><pre>@Test(description = &quot;Search&quot;)<br> public void sort() throws Exception {<br>  Thread.sleep(10000);<br>  Assert.fail();</pre><pre>}</pre><pre>@Test(description = &quot;Select&quot;)<br> public void selectAProduct() throws Exception {<br>  Thread.sleep(10000);<br>  <br> }</pre><pre>@Test(description = &quot;Log Out&quot;)<br> public void goToAboutPage() throws Exception {<br>  Thread.sleep(10000);<br>  <br> }</pre><pre>}</pre><p><strong>Create a new class called <em>InfluxDBListener</em> which implements ITestListner of TestNG and copy &amp; paste the below code there:</strong></p><pre><em>public class InfluxDBListener implements ITestListener {<br><br>  public void onTestStart(ITestResult iTestResult) {<br><br>  }<br><br>  public void onTestSuccess(ITestResult iTestResult) {<br>    this.postTestMethodStatus(iTestResult, &quot;PASS&quot;);<br>  }<br><br>  public void onTestFailure(ITestResult iTestResult) {<br>    this.postTestMethodStatus(iTestResult, &quot;FAIL&quot;);<br>  }<br><br>  public void onTestSkipped(ITestResult iTestResult) {<br>    this.postTestMethodStatus(iTestResult, &quot;SKIPPED&quot;);<br>  }<br><br>  public void onTestFailedButWithinSuccessPercentage(ITestResult iTestResult) {<br><br>  }<br><br>  public void onStart(ITestContext iTestContext) {<br><br>  }<br><br>  public void onFinish(ITestContext iTestContext) {<br>    this.postTestClassStatus(iTestContext);<br>  }<br><br>  private void postTestMethodStatus(ITestResult iTestResult, String status) {<br>    Point point = Point.measurement(&quot;testmethod&quot;).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)<br>        .tag(&quot;testclass&quot;, iTestResult.getTestClass().getName()).tag(&quot;name&quot;, iTestResult.getName())<br>        .tag(&quot;description&quot;, iTestResult.getMethod().getDescription()).tag(&quot;result&quot;, status)<br>        .addField(&quot;duration&quot;, (iTestResult.getEndMillis() - iTestResult.getStartMillis())).build();<br>    UpdateResults.post(point);<br>  }<br><br>  private void postTestClassStatus(ITestContext iTestContext) {<br>    Point point = Point.measurement(&quot;testclass&quot;).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)<br>        .tag(&quot;name&quot;, iTestContext.getAllTestMethods()[0].getTestClass().getName())<br>        .addField(&quot;duration&quot;, (iTestContext.getEndDate().getTime() - iTestContext.getStartDate().getTime()))<br>        .build();<br>    UpdateResults.post(point);<br>  }<br><br>}</em></pre><p>Above listener will monitor the test execution and as soon as a method/test class is executed, it sends the name, duration and few other details.</p><p><strong>Add <em>influxdb-java</em> dependency in your <em>pom.xml</em></strong></p><pre>&lt;dependency&gt;<br>&lt;groupId&gt;org.influxdb&lt;/groupId&gt;<br>&lt;artifactId&gt;influxdb-java&lt;/artifactId&gt;<br>&lt;version&gt;2.12&lt;/version&gt;<br>&lt;/dependency&gt;</pre><p><strong>Lets create a simple class which is responsible for sending the results to InfluxDB.</strong></p><pre>public class ResultSender {<br><br>    private static final InfluxDB INFLXUDB = InfluxDBFactory.connect(&quot;http://localhost:8086&quot;, &quot;root&quot;, &quot;root&quot;);<br>    private static final String DATABASE = &quot;selenium&quot;;<br><br>    static{<br>        INFLXUDB.setDatabase(DATABASE);<br>    }<br><br>    public static void send(final Point point){<br>        INFLXUDB.write(point);<br>    }<br><br>}</pre><p>Here we are setting the Database as “selenium” (which we already added in influxdb)</p><p>Now include the listener in the suite xml or in the base TestNG class.</p><pre><br>&lt;suite name=&quot;My suite&quot;&gt;<br>    &lt;listeners&gt;<br>        &lt;listener class-name=&quot;com.utils.InfluxDBListener&quot; /&gt;<br>    &lt;/listeners&gt;<br>    &lt;test name=&quot;Test1&quot;&gt;<br>        &lt;classes&gt;<br>            &lt;class name=&quot;com.tests.InfluxGrafanaTests&quot;/&gt;<br>        &lt;/classes&gt;<br>    &lt;/test&gt;<br>&lt;/suite&gt;</pre><p><strong><em>Time for Action !!!</em></strong></p><p>Let’s run the tests using testng file. Navigate to Grafana and see the test results updating dynamically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_yUJ2zX1exrZ56LJGGdUxQ.png" /></figure><p>To see the test results updating dynamically watch this below video</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FxejtcYO4TqI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DxejtcYO4TqI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FxejtcYO4TqI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf233a292ca51f3057c70c5a969fc88a/href">https://medium.com/media/cf233a292ca51f3057c70c5a969fc88a/href</a></iframe><p>Hope this project was interesting in setting up the real time results using InfluxDB and Grafana . This article gives only a high level idea.You could further enhance this according to your needs.</p><p>Thanks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4606ad80781c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Introduction to Using Selenium Automation Scripts-Docker Containers for End-to-End Testing]]></title>
            <link>https://medium.com/@kishansk26/an-introduction-to-using-selenium-automation-scripts-docker-containers-for-end-to-end-testing-5a94b58077bd?source=rss-1dadcd3b204c------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a94b58077bd</guid>
            <category><![CDATA[selenium]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Kishan Enjapuri]]></dc:creator>
            <pubDate>Wed, 16 Oct 2019 15:19:15 GMT</pubDate>
            <atom:updated>2019-10-16T15:19:15.302Z</atom:updated>
            <content:encoded><![CDATA[<h3>An Introduction to Using Selenium-Docker Containers for End-to-End Testing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*1QgK5uEKIzC0cI5iRrP5kg.png" /></figure><p><em>As Docker technology gains more popularity among Automation Test Engineers ,it’s becoming increasingly important for programmers to grasp the basics of docker. Here we learn why Docker is at the center of cloud IT era hype, as well as to learn how to run selenium automation scripts on docker.</em></p><p>Before learning about basics of docker lets see what is <strong>Virtualization </strong>and <strong>Containerization </strong>and how are they related to <strong>Docker </strong>:</p><p>V<strong>irtualization: </strong>A virtual machine is a copy of a complete server basically it has its own OS which means the replication of binaries, drivers, or libraries between different VMs running on same server and a wastage significant server resources.</p><p>C<strong>ontainerization: </strong>Containerization is a lightweight alternative to full machine virtualization that involves encapsulating an application in a container with its own operating environment.</p><p>Containers use the same host operating system (OS) repeatedly, instead of installing an OS for each guest VM.</p><p>Containers also provide a way to isolate applications and provide a virtual platform for applications to run on .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UEmLmenrxKp0Hwid4xxGwQ.png" /></figure><h3>What Is A Docker?</h3><p>Docker is a platform which packages an application and all its dependencies together in the form of containers. This containerization aspect of Docker ensures that the application works in any environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*pOEePVxIET7PL2btI-LqxQ.png" /></figure><p>As you can see in the diagram, each and every application runs on separate containers and has its own set of dependencies &amp; libraries. This makes sure that each application is independent of other applications, giving developers surety that they can build applications that will not interfere with one another.</p><p>So a developer can build a container having different applications installed on it and give it to the QA team. Then the QA team would only need to run the container to replicate the developer’s environment.</p><h3>Docker Explained: Dockerfile, Images &amp; Containers</h3><p>Dockerfile, Docker Images &amp; Docker Containers are three important terms that you need to understand while using Docker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZLHzoyDXYY8YtJ-M.png" /></figure><p>As you can see in the above diagram when the Dockerfile is built, it becomes a Docker Image and when we run the Docker Image then it finally becomes a Docker Container.</p><p>Refer below to understand all the three terms.</p><p><strong>Dockerfile: </strong>A Dockerfile is a text document which contains all the commands that a user can call on the command line to assemble an image. So, Docker can build images automatically by reading the instructions from a Dockerfile. You can use docker build to create an automated build to execute several command-line instructions in succession.</p><p><strong>Docker Image:</strong> In layman terms, Docker Image can be compared to a template which is used to create Docker Containers. So, these read-only templates are the building blocks of a Docker Container. You can use docker run to run the image and create a container.</p><p>Docker Images are stored in the Docker Registry. It can be either a user’s local repository or a public repository like a Docker Hub which allows multiple users to collaborate in building an application.</p><p><strong>Docker Container: </strong>Docker Container is a running instance of a Docker Image as they hold the entire package needed to run the application. So, these are basically the ready applications created from Docker Images which is the ultimate utility of Docker.</p><h4>Pre-Requisites:</h4><ul><li>Docker installed in the Local machine.</li><li>JDK 1.7 or above.</li><li>All web browsers installed on Local machine.</li><li>Selenium WebDriver + JAVA + TestNG test cases.</li><li>If you are running on Windows machine you need to have Windows 10 OS because docker supports only in Windows 10.</li><li>If you are running on MAC machine then you need to have Apple Mac OS Yosemite 10.10.3 or above.</li></ul><p>You can download the docker for Windows from <a href="https://store.docker.com/editions/community/docker-ce-desktop-windows">here</a> &amp; for Mac from <a href="https://store.docker.com/editions/community/docker-ce-desktop-mac">here</a>.</p><p>Steps to be followed when installing docker:</p><ul><li>Once the binaries are downloaded, install the docker.</li><li>Turn ON the virtualization in the local machine.</li><li>Open the docker and click on the checkbox &amp; expose Daemon on TCP://localhost. This allows to makes yourself vulnerable to remote execution attacks.</li><li>Once Docker is installed,an icon gets created on the desktop , click on the docker icon.</li><li>open the command prompt and type <em>Docker –info </em>— this will give all the information about the installed docker.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bmbzKaO94tw81icgyvKZyA.png" /></figure><p>To run the selenium webdriver scripts with docker you need to download the following image and add to the docker container.</p><p>selenium/standalone-chrome— To access the chrome browser</p><p>Commands to download the image:</p><blockquote><strong>docker pull selenium/standalone-chrome:latest</strong></blockquote><p>Then you need to start the chrome node.For starting the node run the following command from the command prompt.</p><blockquote><strong>docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:latest</strong></blockquote><p>Then run the command <strong><em>docker container ls</em></strong>— This command will list all the docker containers installed in the system and running on the port number.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QXXSgcR6w3p6fAExPwadbg.png" /></figure><p><strong>Configuring Selenium Tests:</strong></p><p>Once all the setup is completed, we need to connect our selenium scripts with the selenium hub.</p><p>For connecting to the hub add the below line of snippet in your selenium script</p><blockquote><strong>driver = new RemoteWebDriver (new URL(“http://localhost:portnumber/wd/hub”), capabilities);</strong></blockquote><p><strong>Sample Script:</strong></p><blockquote><em>package docker;</em></blockquote><blockquote><em>import java.net.MalformedURLException;</em></blockquote><blockquote><em>import java.net.URL;</em></blockquote><blockquote><em>import java.sql.Driver;</em></blockquote><blockquote><em>import org.openqa.selenium.Platform;</em></blockquote><blockquote><em>import org.openqa.selenium.WebDriver;</em></blockquote><blockquote><em>import org.openqa.selenium.chrome.ChromeDriver;</em></blockquote><blockquote><em>import org.openqa.selenium.remote.DesiredCapabilities;</em></blockquote><blockquote><em>import org.openqa.selenium.remote.RemoteWebDriver;</em></blockquote><blockquote><em>import org.testng.annotations.Test;</em></blockquote><blockquote><em>public class NewTest {</em></blockquote><blockquote><em>@Test</em></blockquote><blockquote><em>public void dockerimp() throws MalformedURLException {</em></blockquote><blockquote><em>URL url=new URL(“http://localhost:4444/wd/hub&quot;);</em></blockquote><blockquote><em>DesiredCapabilities cap=DesiredCapabilities.chrome();</em></blockquote><blockquote><em>Driver = new RemoteWebDriver(url,cap);</em></blockquote><blockquote><em>driver.get(“https://openweathermap.org/”);</em></blockquote><blockquote><em>System.out.println(driver.getTitle());</em></blockquote><blockquote><em>}</em></blockquote><blockquote><em>}</em></blockquote><p>This will run the selenium script on the docker container .</p><p>Hope this helps you to run automation scripts on docker.</p><p><strong>In this approach we can create selenium grid with hub and multiple nodes (chrome,firefox,etc). So, We are not yet done!! We can still improve the process.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a94b58077bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>