<?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 Udara Sembukuttiarachchi on Medium]]></title>
        <description><![CDATA[Stories by Udara Sembukuttiarachchi on Medium]]></description>
        <link>https://medium.com/@udarasembukuttiarachchi?source=rss-92c13591f761------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pMn33OziVGi3CCjztEuO9Q.jpeg</url>
            <title>Stories by Udara Sembukuttiarachchi on Medium</title>
            <link>https://medium.com/@udarasembukuttiarachchi?source=rss-92c13591f761------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 09:24:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@udarasembukuttiarachchi/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[Hair, My God, and Wheelchair]]></title>
            <link>https://medium.com/@udarasembukuttiarachchi/hair-my-god-and-wheelchair-cf076309330e?source=rss-92c13591f761------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf076309330e</guid>
            <category><![CDATA[speechwriting]]></category>
            <category><![CDATA[communication-skills]]></category>
            <category><![CDATA[public-speaking]]></category>
            <category><![CDATA[communication]]></category>
            <category><![CDATA[toastmasters]]></category>
            <dc:creator><![CDATA[Udara Sembukuttiarachchi]]></dc:creator>
            <pubDate>Sat, 07 Dec 2024 15:42:28 GMT</pubDate>
            <atom:updated>2024-12-07T15:42:28.304Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*SWwR1hQsms1C3SPk0oHXqw@2x.jpeg" /></figure><blockquote><em>“Clear! Clear! We have a female, unresponsive, no pulse.”</em></blockquote><p>When <strong>Luisa Montalvo</strong> rolled onto the stage in a wheelchair and uttered those words as the opening of her final speech at the 2024 World Championship of Public Speaking, I was perplexed — and yet completely intrigued. Where was she taking us over the next seven minutes? This is the very definition of an attention-grabbing opening. And what a journey it was: she took us on an emotional rollercoaster with one of the most controversial winning speeches in the history of the Championship. In this article, I’ll explore the three major norm-breaking elements Luisa introduced in her gem of a speech, “37 Strangers.”</p><p>Before reading the rest, watch this amazing speech if you haven’t watched it already.</p><p>https://youtu.be/OpuMNgxRMac?si=akKGTfd953Fv6P7z</p><h3>Opening with Hair on Her Face</h3><p>One of the first pieces of advice I received when I began giving speeches at Toastmasters was on how to start a speech effectively. The standard guidance is to stand centre-stage, make eye contact, and deliver a captivating opening — always with a smile. But Luisa did the exact opposite. In the opening seconds of her speech, we couldn’t see her face; her hair covered it as she mimicked the words spoken by paramedics. She had no eye contact with the audience, no smile, and all we could see was her grey hair.</p><p>In an interview, Luisa later explained her thought process. She wanted her audience to envision her as dead. Her opening lines weren’t her own but rather the dialogue of paramedics. By choosing to stay true to the characters in her story, Luisa encouraged the audience’s imagination over typical speech-starting norms. Right from that start, she made her mark as a brave and unconventional contestant.</p><h3>Joke about “My God”</h3><p>Another piece of advice that Sri Lankan Toastmasters often receive is, “Don’t talk about sex, politics, or religion.” These are considered taboo topics and are usually avoided. But Luisa boldly incorporated an imaginative story about God and Peter, even turning it into a joke by saying:</p><p>“Oh, and I say My God, because I don’t want to offend some of you…</p><p>I want to offend all of you.”</p><p>This felt like a direct challenge to the misconception that taboo topics are forbidden in Toastmasters. It’s worth noting that there’s actually no such restriction in Toastmasters guidelines. As stated on the Toastmasters International website:</p><p>“Members often hear that speeches about politics, religion, and sex are forbidden by Toastmasters International because they are controversial. This is not true. Toastmasters International does not prohibit any speech topic, content, or language.”</p><p>The concept of taboo topics likely originated from the Arab Toastmasters clubs due to cultural sensitivities, which was later adopted in India and eventually passed on to Sri Lanka. But would I encourage Sri Lankan Toastmasters to go that far? Given that a stand-up comedian was once arrested in Sri Lanka for a similar joke, probably not.</p><h3>No Purposeful Stage Movements</h3><p>Stage usage, <em>really?</em> After a near-fatal accident, she was lucky to even be on that stage. Yet, I heard some well-meaning Toastmasters question, “How could she win the World Championship without scoring on stage movement?”</p><p>The fact is, prior to the 1980s, all Toastmasters speeches were delivered from behind a lectern without any stage movement. The practice of purposeful stage movements only gained popularity later to enhance audience engagement. But was there any lack of engagement in Luisa’s speech? Far from it. She captivated the audience with a beautifully crafted speech, relying on vocal delivery, facial expressions, and even some vertical movement: she rose from the wheelchair with all her strength to speak directly to the audience. If that doesn’t enhance audience experience, I don’t know what would.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*RXYURWe9E7RqCEwzqDPY6Q@2x.jpeg" /></figure><p>Luisa Montalvo lost the World Championship once to Aaron Beverly in 2019, survived a life-threatening accident, and then returned in a wheelchair to the World Championship stage to win — breaking norms like a true champion. She reminds us that what is traditional today was not necessarily the norm yesterday, and true champions are those who go beyond conventions, breaking traditions and creating new ones on the journey to victory!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf076309330e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s find that missing JSON record…]]></title>
            <link>https://medium.com/@udarasembukuttiarachchi/lets-find-that-missing-json-record-dabd54a76f4e?source=rss-92c13591f761------2</link>
            <guid isPermaLink="false">https://medium.com/p/dabd54a76f4e</guid>
            <category><![CDATA[compare]]></category>
            <category><![CDATA[json]]></category>
            <category><![CDATA[jq]]></category>
            <category><![CDATA[diff]]></category>
            <category><![CDATA[qa]]></category>
            <dc:creator><![CDATA[Udara Sembukuttiarachchi]]></dc:creator>
            <pubDate>Wed, 01 Nov 2023 13:35:14 GMT</pubDate>
            <atom:updated>2023-11-01T13:35:14.254Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*eNN0YyaL8CbjAcZS" /></figure><p>As a quality engineer who works with a backend team of a large, multi national, fortune 500 company, I was presented with an interesting challenge recently. My team was getting prepared for a huge data migration. We were to receive over 700,000+ records in JSON format files which will be run through a Java CLI (Command Line Interface) tool to persist in our Database. The challenging part was, if and when a record goes missing during the migration process, how can we identify the missing record? It will be like searching for a needle in a haysack for sure!</p><p>After a successful migration run, my team was able to generate another JSON file of all the records persisted in the Database. So, what’s the challenging part; it’s a simple comparison of two json files, isn’t it?</p><p>Usually, yes. But here the circumstances were different.</p><p><strong>a.</strong> We cannot use any online JSON compare tools because the data is sensitive. It’s against our cyber security policies and the best practises to publish such data anywhere outside of the organization.</p><p><strong>b.</strong> We cannot use the compare feature in Visual Studio Code (if you didn’t know, yes there’s such a feature) for two reasons. As I said in the bigining, our JSON files were huge and and it will take so much out of a local machine’s resources to do such a comparison. And also, the migration happened in a cloud computer, an AWS ec2 instance which has no GUI(Graphical User Interface). But rather than transferring these bulky JSON files here and there, it seemed easy to do the comparison at the EC2 machine itself.</p><p>C. We don’t want to know each and every attribute of a missing JSON object as a single JSON object is bulky itself. We just want to know the id of a missing object and that’s it.</p><p>So what is the solution?</p><h3>“jq” to the rescue…</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3ugOGWc-S0BbyZqigQxmJA.png" /></figure><p>“jq” is a lightweight and flexible command-line JSON processor. You can use it to easily slice and filter and map and transform structured JSON data.</p><p>for example the bellow command will filter out the first index out of an array of JSON objects in the foo.json file.</p><pre>jq &#39;.[0]&#39; foo.json</pre><h3>Let’s create some sample data to play with…</h3><p>Since I cannot publish the real data set I used in this article, I will give you an example on how to use jq for the purpose of JSON comparing using a freely available large JSON file. You can find the file I used here:</p><p><a href="https://github.com/json-iterator/test-data/blob/master/large-file.json">test-data/large-file.json at master · json-iterator/test-data</a></p><p>Here’s a look at the sample data in my JSON file:</p><pre>[{&quot;id&quot;:&quot;2489651045&quot;,&quot;type&quot;:&quot;CreateEvent&quot;,&quot;actor&quot;:{&quot;id&quot;:665991,&quot;login&quot;:&quot;petroav&quot;,&quot;gravatar_id&quot;:&quot;&quot;,&quot;url&quot;:&quot;https://api.github.com/users/petroav&quot;,&quot;avatar_url&quot;:&quot;https://avatars.githubusercontent.com/u/665991?&quot;},&quot;repo&quot;:{&quot;id&quot;:28688495,&quot;name&quot;:&quot;petroav/6.828&quot;,&quot;url&quot;:&quot;https://api.github.com/repos/petroav/6.828&quot;},&quot;payload&quot;:{&quot;ref&quot;:&quot;master&quot;,&quot;ref_type&quot;:&quot;branch&quot;,&quot;master_branch&quot;:&quot;master&quot;,&quot;description&quot;:&quot;Solution to homework and assignments from MIT&#39;s 6.828 (Operating Systems Engineering). Done in my spare time.&quot;,&quot;pusher_type&quot;:&quot;user&quot;},&quot;public&quot;:true,&quot;created_at&quot;:&quot;2015-01-01T15:00:00Z&quot;}<br>,{&quot;id&quot;:&quot;2489651051&quot;,&quot;type&quot;:&quot;PushEvent&quot;,&quot;actor&quot;:{&quot;id&quot;:3854017,&quot;login&quot;:&quot;rspt&quot;,&quot;gravatar_id&quot;:&quot;&quot;,&quot;url&quot;:&quot;https://api.github.com/users/rspt&quot;,&quot;avatar_url&quot;:&quot;https://avatars.githubusercontent.com/u/3854017?&quot;},&quot;repo&quot;:{&quot;id&quot;:28671719,&quot;name&quot;:&quot;rspt/rspt-theme&quot;,&quot;url&quot;:&quot;https://api.github.com/repos/rspt/rspt-theme&quot;},&quot;payload&quot;:{&quot;push_id&quot;:536863970,&quot;size&quot;:1,&quot;distinct_size&quot;:1,&quot;ref&quot;:&quot;refs/heads/master&quot;,&quot;head&quot;:&quot;6b089eb4a43f728f0a594388092f480f2ecacfcd&quot;,&quot;before&quot;:&quot;437c03652caa0bc4a7554b18d5c0a394c2f3d326&quot;,&quot;commits&quot;:[{&quot;sha&quot;:&quot;6b089eb4a43f728f0a594388092f480f2ecacfcd&quot;,&quot;author&quot;:{&quot;email&quot;:&quot;5c682c2d1ec4073e277f9ba9f4bdf07e5794dabe@rspt.ch&quot;,&quot;name&quot;:&quot;rspt&quot;},&quot;message&quot;:&quot;Fix main header height on mobile&quot;,&quot;distinct&quot;:true,&quot;url&quot;:&quot;https://api.github.com/repos/rspt/rspt-theme/commits/6b089eb4a43f728f0a594388092f480f2ecacfcd&quot;}]},&quot;public&quot;:true,&quot;created_at&quot;:&quot;2015-01-01T15:00:01Z&quot;}<br>,{&quot;id&quot;:&quot;2489651053&quot;,&quot;type&quot;:&quot;PushEvent&quot;,&quot;actor&quot;:{&quot;id&quot;:6339799,&quot;login&quot;:&quot;izuzero&quot;,&quot;gravatar_id&quot;:&quot;&quot;,&quot;url&quot;:&quot;https://api.github.com/users/izuzero&quot;,&quot;avatar_url&quot;:&quot;https://avatars.githubusercontent.com/u/6339799?&quot;},&quot;repo&quot;:{&quot;id&quot;:28270952,&quot;name&quot;:&quot;izuzero/xe-module-ajaxboard&quot;,&quot;url&quot;:&quot;https://api.github.com/repos/izuzero/xe-module-ajaxboard&quot;},&quot;payload&quot;:{&quot;push_id&quot;:536863972,&quot;size&quot;:1,&quot;distinct_size&quot;:1,&quot;ref&quot;:&quot;refs/heads/develop&quot;,&quot;head&quot;:&quot;ec819b9df4fe612bb35bf562f96810bf991f9975&quot;,&quot;before&quot;:&quot;590433109f221a96cf19ea7a7d9a43ca333e3b3e&quot;,&quot;commits&quot;:[{&quot;sha&quot;:&quot;ec819b9df4fe612bb35bf562f96810bf991f9975&quot;,&quot;author&quot;:{&quot;email&quot;:&quot;df05f55543db3c62cf64f7438018ec37f3605d3c@gmail.com&quot;,&quot;name&quot;:&quot;Eunsoo Lee&quot;},&quot;message&quot;:&quot;#20 게시글 및 댓글 삭제 시 새로고침이 되는 문제 해결\n\n원래 의도는 새로고침이 되지 않고 확인창만으로 해결되어야 함.\n기본 게시판 대응 플러그인에서 발생한 이슈.&quot;,&quot;distinct&quot;:true,&quot;url&quot;:&quot;https://api.github.com/repos/izuzero/xe-module-ajaxboard/commits/ec819b9df4fe612bb35bf562f96810bf991f9975&quot;}]},&quot;public&quot;:true,&quot;created_at&quot;:&quot;2015-01-01T15:00:01Z&quot;}<br>...</pre><p>With the sample JSON file I downloaded, I made two copies named large-file-input.json and large-file-output.json, and here are the differences between those two files.</p><p><strong>a.</strong> I deliberately removed one JSON object from the output file to create a scenario where data went missing during the migration.</p><p><strong>b.</strong> I duplicated one JSON object in the input file. This is because in a data migration source file, there could be duplicate records, but in the database only unique records are persisted. In our comparison these duplicate records should not be identified as missing records.</p><h3>It’s time for action…</h3><p>In your preferred terminal, check for jq version. If jq is not already installed here are the instructions to get it installed:</p><p><a href="https://jqlang.github.io/jq/download/">Download jq</a></p><p><strong><em>Note:</em></strong> I’ll be using MacOS iTerm2 terminal and all the commands will be in UNIX style in the following examples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KUJp615qRfcN9PZo50Trhw.png" /><figcaption>jq version 1.7 installed.</figcaption></figure><p>Now using the ‘<strong>length</strong>’ argument in jq, let’s count the json objects in the input file and the output file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nPvEDQxBNqoVz4HKy1FZnA.png" /></figure><p>As you can see there are 11,352 objects in the input file and 11,350 objects in the output file. There’s a difference of 2 records. One record we removed deliberately. The other record is the duplicate record we created in the input file.</p><p>My target is to identify the distinct missing id from the input JSON. For this purpose, the command should look like this.</p><pre>diff &lt;(jq &#39;unique | sort_by(.id) | .[].id&#39; large-file-input.json) &lt;(jq &#39;sort_by(.id) | .[].id&#39; large-file-output.json)</pre><h3>Let me explain the command briefly…</h3><p><strong>diff</strong></p><p>diff is another CLI tool that we can use to find the difference between two files. Instead of comparing two files we are going to use the power of <strong>process substitution</strong> in bash scripting and compare the outputs of two jq commands directly. Without the jq commands, the structure of the diff command looks like this.</p><p><em>diff &lt;( //output from the jq command 1) &lt;(//output from the jq command 2)</em></p><p><strong>jq Command 1</strong> — <em>jq ‘unique | sort_by(.id) | .[].id’ large-file-input.json</em></p><p>Here the ‘<strong>unique</strong>’ argument is used to get the distinct ids only.</p><p><strong>sort_by()</strong> in jq sorts a JSON array by a given attribute — here it’s id.</p><p><em>The purpose of </em><strong><em>.[].id </em></strong><em>is to iterate through each object of JSON array and select the id attributes only.</em></p><p>finally we have to give the path of the json file to be filtered.</p><p><strong>jq Command 2</strong>— <em>jq ‘sort_by(.id) | .[].id’ large-file-output.json</em></p><p>The only difference here is we have omitted the ‘unique’ arguement because we know that for sure there won’t be any duplicate ids in the JSON we generate from the databse.</p><p>Finally, when we run the whole command, we get an output like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qjubFGM9O5OTXM_j1b-s5A.png" /></figure><p>You can see that the id of the missing object is given as the output and our purpose is achieved.</p><p>So that’s it folks. As always, happy scripting!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dabd54a76f4e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Inspecting DOM Elements in Headless Mode]]></title>
            <link>https://medium.com/@udarasembukuttiarachchi/inspecting-dom-elements-in-headless-mode-265d78fc0732?source=rss-92c13591f761------2</link>
            <guid isPermaLink="false">https://medium.com/p/265d78fc0732</guid>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[chrome]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[headless]]></category>
            <dc:creator><![CDATA[Udara Sembukuttiarachchi]]></dc:creator>
            <pubDate>Tue, 26 Apr 2022 13:05:00 GMT</pubDate>
            <atom:updated>2022-04-27T02:52:11.713Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*22YXksgHcE6IkLH6.gif" /></figure><h3>How did a browser lose its head!?</h3><p>Headless browsers have become quite popular among Automation Engineers as well as Web-Scrapers in the modern IT world. But if you are not one of those people, you may wonder what these headless browsers are. Think like this; the browsers you use in your day-to-day work have a head and a body. Head is the beautiful User Interfaces (UI) you see of websites. Body is the ugly HTML code, or to be more precise the DOM (Document Object Model), you see when you inspect a website or look into the source code of the website. In headless browsers, you don’t get to see the beautiful UIs as the name suggests now. Instead, they run without any UI but creating the DOM behind the scenes. Therefore, headless browsers are useless for typical users who want to surf the web, but priceless for Automation Engineers and Web-scrapers as they can run automated bot-like solutions in their tests and web-scrapping activities completely eliminating any slowness generated by the heavy UIs of modern-day websites. Few examples for popular headless browsers are:</p><p>1. Google Chrome headless mode</p><p>2. Firefox headless mode</p><p>3. PhantomJS</p><p>4. Zombie.js</p><p>5. HtmlUnit</p><h3>But here comes trouble….</h3><p>When it comes to test automation, identifying elements in a web page is the most difficult thing in my experience, not the writing of testcases. The typical way of doing this is to inspect the UI and look into the DOM and finding a Xpath or a CSS Selector which can uniquely identify the element we need. But this cannot be done in a headless browser alone, because when a headless browser is running, we don’t see a UI to inspect at all. So, what we usually do is, we first identify the elements using a real browser like Chrome and create tests to be run in headless browsers later. But, recently I faced a scenario where this method didn’t help me at all.</p><p>I had to create an automation test script for a web app which uses Google IDP services for authentication. As usual I identified all the elements needed in the google login form, created few tests, and ran them in Chrome headless mode. The results were shocking; all tests had failed due to an error in element identification. I had configured the test suite to take screenshots when the tests fail (there are some automation tools that help you to take screenshots even in headless mode), and looking into the screen shots I was double shocked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xnYpe6oLZKnYgJNMskOrQg.png" /><figcaption>Screenshot taken from a real Chrome browser</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-w78PLmixJCbN-THcqq0kQ.png" /><figcaption>Screenshot taken by the Automation Suite rendering the headless mode DOM on failure of the test</figcaption></figure><p>As you can see google authentication forms have completely different UIs in real browser screenshots and headless mode screenshots. Some web apps like Google does this to optimize the user experience. They serve users different versions of their web app depending on the device and the browser users use. But this is bad news for an Automation Engineer like me; this means I have to identify the elements that appear in headless mode separately. But how to do that?</p><h3>Here comes the Saviour…</h3><p>Luckily, there’s a fairly simple solution. <strong>Chrome DevTools</strong> now provide debug facilities for headless mode too. Let me show you how to do this step by step in Windows OS (In Linux and MacOS the commands used below might be slightly different, but the steps are the same):</p><p>1. Open a command prompt and navigate to the installed location of Google Chrome. In my machine the location is:<br>C:\Program Files\Google\Chrome\Application<br> <br> <strong><em>$ cd C:\Program Files\Google\Chrome\Application</em></strong></p><p>2. Start a Google Chrome instance with the following command<br> <br><strong><em> $ chrome --headless --disable-gpu --remote-debugging-port=9222 &lt;Url of the web application you want to test&gt;</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rDhI_u7xXUsY2VvWEfyE9g.png" /></figure><p>Explanation to the flags in the command:</p><p>a. <strong>--headless</strong> : chrome should start in headless mode</p><p>b. <strong>--disable-gpu</strong> : This flag is only needed for Windows</p><p>c. <strong>--remote-debugging-port</strong> : starts an instance with the DevTools protocol enabled.</p><p>d. <strong>9222 </strong>: default port which DevTools remote network targets</p><p>3. Next, start a real Chrome browser and navigate to <strong><em>chrome://inspect. </em></strong>You will see a page like in the screenshot. You should see the URL you want to inspect now under the <strong>Remote Target</strong> section</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vwPdf1-f9knFZlX0ZFjykA.png" /></figure><p>If you can’t find your URL or if the Remote Target section is empty, that means your chrome headless browser session didn’t start properly with remote debugging. You can either kill any ongoing process in port 9222 then restart a headless mode session or try with a different port.</p><p>4. Click the <strong><em>inspect</em></strong> button under the URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kvkxniPf8H7XFguw-93_sw.png" /></figure><p>You will see a new window open in the inspect mode with the web page you want to inspect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lQTo9Emg1o4xD4Fq4ah6bQ.png" /></figure><p>The UI rendered here is how a headless browser would render it. Therefore, you can easily identify the necessary elements inspecting here.</p><p>That’s it my friends. Happy testing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=265d78fc0732" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Can we automate a login with Two-factor authentication?]]></title>
            <link>https://medium.com/@udarasembukuttiarachchi/can-we-automate-a-login-with-two-factor-authentication-1eb28ee5d729?source=rss-92c13591f761------2</link>
            <guid isPermaLink="false">https://medium.com/p/1eb28ee5d729</guid>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[two-factor-authentication]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Udara Sembukuttiarachchi]]></dc:creator>
            <pubDate>Sat, 28 Aug 2021 10:52:49 GMT</pubDate>
            <atom:updated>2021-08-28T15:20:55.345Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*fiV5TAfFCYMT6lD4.jpg" /></figure><p>That, my friends, is a question I had to answer in a Test Automation project I’ve been working on for a while. Our client is a very security-concerned organization and they had made it compulsory to use Two-factor authentication for every login. Now, if you are wondering what this “Two-factor authentication”(referred as <strong>2FA</strong> hereafter) means, I’m sure you might have come across it in many of your day-to-day application logins; it is the process where you have to verify whether it’s actually you who’s trying to login using a different device, preferably your mobile phone, tapping “Yes it’s me” or entering a One-time-password (<strong>OTP</strong>). The challenge I had to face as a Test Automation Engineer is to write a test script where the login can be automated without a person manually doing the 2FA each time the script runs. Let’s now see step-by-step how I overcame this challenge.</p><p><em>Note:</em><br>The scenario I’m going to show you is explained referring to <strong>Google IdP</strong>(Google IdP is a user management platform for Google Apps and services), and the test automation tool used is <strong>Testcafe</strong>(a Node.js based test automation tool). But if you grasp the essence behind it, this can easily be applied in any other 2FA based login service using any test automation tool available.</p><h3>Install npm package Authenticator</h3><p>In your test automation project add the npm package Authenticator running the following command.</p><p><strong><em>npm install authenticator — save</em></strong></p><p>Authenticator helps us to generate the OTP needed for 2FA verification.</p><h3><strong>Install Google Authenticator</strong></h3><p>In your mobile device which you are going to use as your secondary device of verification, install Google Authenticator app. This app is available in both Apple appstore and Google playstore.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*7tP1JBy_WtT52ukT6IQsiQ.png" /></figure><h3>Configuring google account 2FA settings</h3><p>Sign into your <strong>Google Account</strong> and navigate to <strong>Security </strong>tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BgHhex_vHL1QjDZ2g9UCKg.png" /></figure><p>In the security page, click on the option “<strong>2-steps verification</strong>”, that will take you to the page where you can set up your preferable 2FA options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pHHRZhFdDxki5LqfixGkuQ.png" /></figure><p>Find the <strong>Authenticator app </strong>option and click on set up. You will get a popup to choose your device type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*nAilMa7018k9z9zodn2WiQ.png" /></figure><p>When you click on Next after choosing your device type you will get a popup with a QR code. Do not scan that QR code. I repeat, DO NOT SCAN THE QR CODE!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*y8jHocbCjz-3Mu9O4tHdPQ.png" /></figure><p>Click on the “<strong>Can’t scan it</strong>?” below the QR code. Yes, you may have the perfect camera to scan the QR code, but this is not the time to be that honest! ;-)</p><p>You will get a popup like below to set up 2FA using a “<strong>Secret-Key</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*Aj7tVvXocHUnQLfvih2qjw.png" /></figure><p>Follow the instructions provided in the popup and setup your OTP generator in the Google Authenticator app you installed in your mobile phone. Save your secret key at a secure location, because we are going to need that later in our automation script.</p><p>Complete the setup by providing the OTP generated from the Google Authenticator app in your mobile phone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*JjdTA3fboQMeN5-qz-GXHw.png" /></figure><h3>Generating the OTP in your test script</h3><p>In your test script, first import the <em>generateToken </em>function from the npm package <em>Authenticator.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*AS_aqHVcf6bfKQrzdw4Lcg.png" /></figure><p>Then, use the <strong>generateToken </strong>function to generate an OTP. This is where we need the <strong>secret key</strong> we previously saved. We have to provide the secret key as an argument to the generateToken function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9fpxI1eeImTIrzYijwcHcQ.png" /></figure><p>Once this is done, it is a matter of providing the generated OTP to the correctly identified input box in your login process. In Testcafe you can do this using typeText command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J6aqkkUjJLPR90NvGoOAKw.png" /></figure><p>That’s it. Congratulations! Automating an application with Two-factor authentication is not a challenge for you anymore! :-D</p><p><strong><em>Pro tip:<br></em></strong>It’s not wise to expose your secret key in a test script as it is a sensitive piece of information. In Testcafe you have the ability to provide those passwords and secret keys through System Environment Variables. Save your secrets in your own environment variables and provide them to test script using <strong><em>process.env property.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oz_m_QExl-NiBh_SuNv6kA.png" /></figure><p><em>Enjoy scripting! :-D</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1eb28ee5d729" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data-Driven Testing with Selenium, TestNG and Microsoft Excel]]></title>
            <link>https://medium.com/@udarasembukuttiarachchi/data-driven-testing-with-selenium-testng-and-microsoft-excel-d1f1e3f0aa86?source=rss-92c13591f761------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1f1e3f0aa86</guid>
            <category><![CDATA[selenium]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[data-driven]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <dc:creator><![CDATA[Udara Sembukuttiarachchi]]></dc:creator>
            <pubDate>Mon, 09 Mar 2020 07:05:52 GMT</pubDate>
            <atom:updated>2020-03-09T07:05:52.365Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*mE2k1u3LKDcy69Zlvz4NMw.png" /></figure><p>Data-driven testing is always a vital part of a software testing process where an application consumes a large number of unique data. It is important to test such scenarios using external data sources rather than using two or three hard-coded values. In this article, I am going to discuss how this complex task of retrieving data from an external source and running tests on each data can be easily achieved using Selenium, TestNG and Microsoft Excel in four super-easy steps:</p><ol><li>Including “poi-ooxml” libraries to the project</li><li>Making a Java Class to read data from an MS Excel sheet</li><li>Making a Java Class to provide data to the TestNG test script</li><li>Using “@DataProvider” annotation in TestNG script to run tests with retrieved data</li></ol><p>Please note that this article is written on using Selenium with Java as the programming language.</p><h3>1. Including “poi-ooxml” libraries to the project</h3><p>If you have made a Maven project for your selenium test framework, this is the easiest task of all. All you need to do is to include the following lines in the pom.xml files under the dependencies and watch Maven do all the hard work of importing libraries for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*W0CRruQ_FHrLDbSH8mQNjw.png" /><figcaption>Dependency to include poi-ooxml in the project</figcaption></figure><p>In case you are not a fan of Maven, you will have to download all the .jar files of poi-ooxml and include them in the project as external libraries. The project should ideally work, but my advice is, “Why all the hard work? Become a fan of Maven”. (Learn more about Apache Maven by visiting <a href="https://maven.apache.org/what-is-maven.html">https://maven.apache.org/what-is-maven.html</a>)</p><h3>2. Making a Java Class to read data from an MS Excel sheet</h3><p>First, you need to make the excel which you are going to use as the external data source. For that, you can make a new folder under your project directory and include your Excel files with data there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/281/1*Pc9iVvF7R65wDOQQRDKukA.png" /><figcaption>td_users.xlsx file included in the project as the external test data source</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*5D1S1WFSEp3jyFCBhqVXBg.png" /><figcaption>Test data to be used in the test scripts</figcaption></figure><p>Next, you have to read and get all the data from the excel file making a new Java class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RWfuxG8A705n8A3Fabtt_Q.png" /><figcaption>ExcelIO.java file to read test data from external Excel file</figcaption></figure><p>In the above class, you can see that I have made an object of XSSFworkbook which will import the whole workbook( or to be more simple your whole excel file) at the given path as a parameter. Please note that you can make XSSFworkbook objects only for excel files with .xlsx format. Before Microsoft Office 2007, the format used for Excel workbooks was .xls format. To create objects with files with the extension .xls, you can create objects with HSSFworkbook instead of XSSFworkbook and follow the same steps.</p><p>As you know it is possible for one excel workbook to contain many sheets. The next step is to create an object with XSSFsheet and give the “sheet name” you are using to store test data as a parameter. As similar to the above step you can create objects with HSSFsheet for excel files with .xls format.</p><p>You can see that I have created two functions to get the number of columns and number of rows in the sheet which will come handy in the next major step. You can also see that I have created two separate functions to get string values and Numeric values because if you try to get numeric values with the same in-built-function “getStringCellValue()”, it will give you an exception.</p><h3>3. Making a Java Class to provide data to the TestNG test script</h3><p>Next, you have to make a separate class to provide data to the test script. This class will work as the coordinator in between the previous class we made and the test script where we will use the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HHKSYv4tO6pClWQ8PNjJRw.png" /><figcaption>ExcelDataProvider.java class to provide data to test scripts</figcaption></figure><p>You can see that in the above class I have created a two-dimensional Object Array to store data and has assigned the array lengths using the number of rows and number of columns retrieved using the ExcelIO class we made in the previous step. If you notice more closely, you can notice that instead of using the number of rows directly, I have reduced the number by one (rowCount-1). This is because in the actual excel file we have “username” and “password” as headers in the very first row which are useless as data and hence been eliminated by reducing 1 from the total row count. After that, we can traverse through the whole excel sheet using the nested for-loops and assign the value of each cell to the two-dimensional array we just created.</p><h3>4. Using @DataProvider annotation in TestNG script to run tests with retrieved data</h3><p>The final step is to use the retrieved data in the test script using TestNG @DataProvider annotation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gfop5kvfSxezAzoUAEkSwQ.png" /></figure><p>In your TestNG test script, you need to make an object from the previously made class ExcelDataProvider and call the function getTestData() within the @DataProvider annotation provided by the TestNG framework and assign the data to a two-dimensional Object array. There you need to give a name for your data provider function as a parameter value to the @DataProvider. This name can be called in a testcase function by using the same name as a parameter value for the “dataProvider” within the @Test annotation. Notice that you need to have the same number of arguments your testcase function as the number of columns in your excel. If you do not have exactly the same number of arguments as the number of columns you will get an error while running the tests.</p><p>That’s it and you are good to go. TestNG will take care of running as many iterations as you want for each test according to the number of test data rows you have in your data source excel file. Enjoy Data-Driven Testing!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1f1e3f0aa86" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Become A Laughingstock 101]]></title>
            <link>https://medium.com/@udarasembukuttiarachchi/how-to-become-a-laughingstock-101-b575c2866e37?source=rss-92c13591f761------2</link>
            <guid isPermaLink="false">https://medium.com/p/b575c2866e37</guid>
            <category><![CDATA[comedy]]></category>
            <category><![CDATA[speech]]></category>
            <category><![CDATA[public-speaking]]></category>
            <category><![CDATA[humor]]></category>
            <category><![CDATA[humorous]]></category>
            <dc:creator><![CDATA[Udara Sembukuttiarachchi]]></dc:creator>
            <pubDate>Sat, 21 Dec 2019 08:34:31 GMT</pubDate>
            <atom:updated>2019-12-21T08:34:31.341Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7BDi46jEhBkesjgbKOjOdQ.jpeg" /></figure><p>Making someone laugh when tickling is not an option is no laughing matter at all. I learnt this the hard way when I decided to participate in a humorous speech contest for the first time ever in my life at the beginning of this year; Enliven 2019 organized by the University of Colombo Gavel Club. Somehow, I managed to become one of the five finalists but was not fortunate enough to get my hands on the gorgeous trophy. Still, standing tall on the Grand Finale stage (quite literally because I am 6 feet and 1 inch tall), delivering the speech to an audience of hundreds and seeing them all uncontrollably belly-laughing at my punchlines was one of the best feelings in my entire life which will give me goosebumps forever.</p><h3>Starting a story is always difficult</h3><p>After finding some inner courage hidden deep within myself to apply for the contest, a big question mark popped up in my head asking, “What am I going to talk about in my speech that will make the judges and the audience jiggle and giggle?”. I had done a number of table topics and several CC (Competent Communicator) speeches at the weekly meetings of the University of Kelaniya Gavel Club, but neither my mind nor the word document had ever gone blank like that before trying to find the first few words of a speech script. I gave up writing the speech for a while and surfed through YouTube watching videos of three of my favourite comedians: Charlie Chaplin, Rowan Atkinson aka Mr. Bean and the infamous Hollywood action movie hero, Jackie Chan.</p><h3>Lessons from the master of silence</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/0*8KeED_qDCYqujknS.jpg" /><figcaption>Charlie Chaplin in <em>Modern Times</em> (1936). © Roy Export Company Establishment; photograph, the Museum of Modern Art/Film Stills Archive, New York City.</figcaption></figure><p>My most favourite performance of Charlie Chaplin could be seen in his character of the infamous persona as “The Tramp” in the movie Modern Times (1936), a silent movie written and directed by the great Chaplin himself. Chaplin’s speciality is that he could kill his audience with laughter without using a single bullet of dialogues. Chaplin is the best evidence to prove that humorous speeches or any other comedy performances are not just about using funny dialogues but bringing out the jokes through facial expressions, body language and the right gestures.</p><h3>A little stupidity wouldn’t hurt</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Qxgv06rZ9BJiBFrq.jpg" /><figcaption>Rowan Atkinson re-enacting a famous scene from the episode “Do-It-Yourself Mr. Bean” on a Mini at Goodwood Circuit Revival 2009 © Wikipedia.</figcaption></figure><p>I remember watching Mr. Bean for the very first time as a five-year-old kid at one of my cousin’s place on a VHS cassette player. Since then, Mr. Bean has been my go-to TV show whenever I feel stressed or depressed and full of negative thoughts. Mr. Bean’s character has that magical touch that can heal our souls with the medicine of laughter. But why do we all love to laugh at Mr. Bean? Mr. Bean acts in a very childish manner with extremely witty motives. Partially, Mr. Bean is crazy, and it is human nature to laugh at crazy people doing crazy things. This means every humorous speaker needs to be a little bit insane too.</p><h3>You need to humiliate YOURSELF</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*oCDHTJ05dqzs1sIi.jpg" /><figcaption>© Forbes | Photo by Ethan Pines.</figcaption></figure><p>From Drunken Master (1978) to The Spy Next Door (2010), and his infamous performance as Detective Lee in the Rush Hour movie trilogy (1998–2007), Jackie Chan was able to captivate the whole world with his breath-taking stunt acting and delightful little jokes. Whenever Jackie missed one of his punches and got hit by the same chair-leg he used to attack his enemy, the whole audience of a cinema would crack into a huge laughter. This is the speciality of Jackie Chan’s comedy style. He brings out comedy material through his own failures in action, and it is the typical human nature to always laugh at some other’s failure. Self-humiliation is one of the most powerful weapons in a humorous speaker’s arsenal and mastering to use that weapon effectively is no easy task at all. The trickiest part of using self-humiliation is to be sure that none of the members in the audience get offended by your silly jokes.</p><h3>Putting things together</h3><p>Watching the performances of the above three legends of comedy helped me to brainstorm and find a topic for my humorous speech: “Let me flirt with you”, and every time a Madam contest-chair read the topic aloud, she giggled. The speech was built around a storyline where I try to flirt with girls but fail each time because of something stupid I would do. I started the speech by asking the audience a question which is a well-renowned technique to grab the audience’s attention and engage the audience with the speaker throughout a speech.</p><p><em>“How many of you think that I am single?”</em> After a little pause, I asked the same question with a little modification as the punchline of my starting joke: “<em>How many of you WISH that I am single?”</em></p><p>Another technique that I used in Enliven 2019 and hugely succeeded was using famous abbreviations and giving them not-so-famous meanings. Following quote is taken from my Enliven 2019 humorous speech.</p><blockquote>Little by little I learnt the art of abbreviation texting. It was not that difficult. All you had to do is to take a phrase and put together the first letter of each word. Finally, I was prepared enough to do the courageous thing: <br>“Hiruni, I think… I L U” — I Love You.</blockquote><blockquote>And immediately she replied:<br>“I D K I H 2 T A I” — I Don’t Know I Have to Think About It!</blockquote><blockquote>Hiruni took 4 days before she texted me with “I L U 2”. It finally happened. Wow, That’s Fantastic right? So, I texted her the very same thing expressing my feelings. <br>“W T F” — Wow That’s Fantastic! Next thing I knew, I was blocked. To this date, I don’t understand what went wrong. Pfff Girls — They are so complex!</blockquote><h3>Just do it!</h3><p>The risk of doing a humorous speech is that you cannot always guarantee that the audience will love your jokes and laugh till their jaws ache and eyes wet. It takes an enormous amount of courage to make yourself a total idiot and provide the audience the time of their lifetime. But once you finish your performance saying, “Over to you, Contest-Chair” and look at the glittering eyes of the audience who would applaud you as hard as they can, I guarantee that it would be the best time of your lifetime. After all, as Chaplin once said, “Laughter is the tonic, the relief, the surcease from pain!”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UCrU23tJEGk8X6RW" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b575c2866e37" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>