<?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 MP on Medium]]></title>
        <description><![CDATA[Stories by MP on Medium]]></description>
        <link>https://medium.com/@randombites?source=rss-26f78b68074d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_AkAfzlJL-AvqPZ2.jpg</url>
            <title>Stories by MP on Medium</title>
            <link>https://medium.com/@randombites?source=rss-26f78b68074d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 16:17:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@randombites/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[Principles of Well working Test Automation In an Organisation]]></title>
            <link>https://randombites.medium.com/principles-of-well-working-test-automation-in-an-organisation-1671db250db7?source=rss-26f78b68074d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1671db250db7</guid>
            <category><![CDATA[test-automation-strategy]]></category>
            <category><![CDATA[testing-principles]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[testing-pyramid]]></category>
            <dc:creator><![CDATA[MP]]></dc:creator>
            <pubDate>Sat, 05 Dec 2020 12:33:32 GMT</pubDate>
            <atom:updated>2020-12-05T12:33:32.104Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I came across a question from one my friend what are “Principles of Well working Test Automation in an Organisation”. So here are my thoughts on it.</p><p>To think about the above question one requires thinking from first principles(<a href="https://jamesclear.com/first-principles">First Principles: Elon Musk on the Power of Thinking for Yourself)</a>.</p><p><strong><em>Why is there any QA in the team, what problem does QA solve in the product.</em></strong></p><p>QA is there to flag quality issues in the product. Earlier QA can flag quality issues; cheaper it is to build and release the product (<a href="https://xbsoftware.com/blog/cost-bugs-software-testing/#:~:text=After%20the%20release%2C%20the%20overall%20cost%20will%20increase,the%20defect%20removal%20depends%20on%20the%20product%20lifetime%3A">The Cost of Bugs: Why You Can’t Ignore Software Testing — XB Software</a>)</p><figure><img alt="Cost of Defect Found after time t (https://xbsoftware.com/blog/cost-bugs-software-testing/#:~:text=After%20the%20release)" src="https://cdn-images-1.medium.com/max/502/1*J4S-8uuJbmQuBt--4uYY_g.png" /></figure><p><strong><em>So what does Test Automation solve for us QA?</em></strong></p><p>It speeds up the process of flagging quality issues in the product, while we(QA) are away focused on improving quality of other areas of the product.</p><p>This means Test Automation helps team(s) release new iterations of product with confidence at a pace that would not be possible without help from machines.</p><p>Thus we can conclude Principles of Well working Test Automation in an Organisation <strong><em>revolves around how effectively Test Automation can flag quality issues and how early it can detect that.</em></strong></p><p>With this being a clear goal, here are some of the ways to apply these principles —</p><ul><li>Continuous Integration to check code quality…</li></ul><p>A well organised <strong>Continuous Integration</strong> system can help check code quality at every stage of the release. This means, ways to check at unit level any potential defects introduced due to change in code. Ways to check this new change integrates well with other changes coming in and so on till the user interface layer.</p><ul><li>Well Architected Test Automation ( Testing Pyramid)</li></ul><p>Although Test automation sounds potentially beneficial, it can quickly become a reason for slow release cycles due to badly architected Test Automation. To avoid this one can use <strong>Testing pyramid</strong> (<a href="https://martinfowler.com/articles/practical-test-pyramid.html">https://martinfowler.com/articles/practical-test-pyramid.html</a>) like a north star.</p><ul><li>Code Quality of Test code ( Oops principles, Coding Conventions, Industry Best Practices)</li></ul><p>Test Automation is finally code. Any code that does not follow good practices soon becomes a drag on the system itself. Simple way to avoid this quagmire is to follow simple principles of <strong>Oops</strong>, apply <strong>coding conventions</strong> agreed within the team and continuously look to borrow <strong>best practices from industry</strong></p><p>Do you agree with this, is there something you think there is to add from your experience, I would be happy to learn from you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1671db250db7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Daily Percentage Change]]></title>
            <link>https://randombites.medium.com/daily-percentage-change-90974697c1a0?source=rss-26f78b68074d------2</link>
            <guid isPermaLink="false">https://medium.com/p/90974697c1a0</guid>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[matplotlib]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[pandas]]></category>
            <dc:creator><![CDATA[MP]]></dc:creator>
            <pubDate>Wed, 20 May 2020 19:03:42 GMT</pubDate>
            <atom:updated>2020-05-20T19:03:42.622Z</atom:updated>
            <content:encoded><![CDATA[<p>Percentage of Covid numbers changed over the day</p><p>This is first in series of Statistical Charts I am going to plot as part of my <a href="https://medium.com/@randombites/towards-building-covid-19-tracker-e7e8f7926f2b">Towards Building Covid 19 Tracker</a>.</p><p>Daily Change is difference between today’s numbers and previous numbers.</p><p>Percentage Change would (DailyChange *100/ Today’s numbers)</p><p>With Pandas library in python one can do all this calculation with a single function call pct_change . Here is how you do it</p><pre>df.pct_change()*100 # where df = data frame</pre><p>Lets look at our sample data</p><blockquote><strong><em>date,active_count,cure_count,death_count,migrated,source</em></strong></blockquote><blockquote>12/05/20 07:35:04,46008,22454,<em>2293,</em>1,https://www.mohfw.gov.in/</blockquote><blockquote>13/05/20 08:56:46,47480,24385,<em>2415,</em>1,https://www.mohfw.gov.in/</blockquote><blockquote>14/05/20 14:10:50,49219,26234,<em>2549,</em>1,https://www.mohfw.gov.in/</blockquote><blockquote>15/05/20 09:32:04,51401,27919,<em>2649,</em>1,https://www.mohfw.gov.in/</blockquote><p>For Daily percentage change we would call as follows</p><pre>`df = self.dataf.iloc[:,1:-1].pct_change()*100</pre><p>Once we have this plotting this on Matplotlib needs some manual hand holding since now our data frame is spread across dataframe of pct values and series of date values.</p><p>We want to have this plot</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BjMEYHmNbXDvAuCI_PIv7A.png" /><figcaption>Daily Percentage Change</figcaption></figure><p>There are four parts to this plot.This is an indication to create a Figure using subplots.</p><p>We start by getting handles to figure and subplots as follows</p><pre>fig, ax = plt.subplots()</pre><p>then we start adding information to figure with subplot handle</p><p><strong><em>a.</em></strong><em> PCT values vs Recorded Date</em></p><pre>ax.plot(date_df, vals) # plot date series on x-axis &amp; pct values on y </pre><p>b. Grid to track Datapoints over Date</p><pre>ax.grid(True) # enable grid for the plot</pre><p>c. Highlighting Data points</p><p>To highlight data points, Matplotlib provides format strings. we use “o-” to indicate “o” to be used for data point and “-” for drawing a line between points</p><p>So instead of step “a” code we use following code</p><pre>ax.plot(date_df, vals, &#39;-o&#39;, label=txt)# we will come back to label plot</pre><p>d. Plotting Values at the data points</p><p>Plotting values at a data point is not straight forward. Inorder to achieve this we need to use annotate function. annotate takes 2 parameters namely</p><ul><li>Value</li><li>XY coordinate</li></ul><p>In our case value is the pct value at the data point &amp; xy coordinate is a combination of date index &amp; pct value. Here is how to do that</p><pre>plt.annotate(f&quot;{round(val,2)}%&quot;,xy=[date_df[idx], val])</pre><p>that’s it. This is all that is needed.</p><p>I will add github link soon for complete code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90974697c1a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Robot Framework Gotchas…]]></title>
            <link>https://randombites.medium.com/robot-framework-gotchas-33300d84a62c?source=rss-26f78b68074d------2</link>
            <guid isPermaLink="false">https://medium.com/p/33300d84a62c</guid>
            <category><![CDATA[gotchas]]></category>
            <category><![CDATA[robot-framework]]></category>
            <dc:creator><![CDATA[MP]]></dc:creator>
            <pubDate>Sun, 17 May 2020 14:58:23 GMT</pubDate>
            <atom:updated>2020-06-03T09:36:57.845Z</atom:updated>
            <content:encoded><![CDATA[<p>Navigating Robot Framework maze…</p><p>If you have been using Robot Framework(RF) for longtime or a beginner you will definitely stumble upon following gotchas... Without further Ado here is the list…</p><ol><li><strong>When to use “…” or “\”</strong></li></ol><p>You are trying to write</p><pre>RunKeywordAndReturnIf &lt;condition&gt; &lt;action&gt;</pre><p>and want to make the code look nice so you move action to new line</p><pre>RunKeywordAndReturnIf &lt;condition&gt;</pre><pre> &lt;action&gt;</pre><p>&amp; run the code. You get error</p><p><strong><em>Keyword ‘BuiltIn.Run Keyword And Return If’ expected at least 2 arguments, got 1.</em></strong></p><p>This is because RF reads “\n” as new line and not continuation. You need to add “…” to make it a continuation of the line, so the code now looks like this,</p><pre>RunKeywordAndReturnIf &lt;condition&gt;</pre><pre>… &lt;action&gt;</pre><p>This brings us to the question, can I use “\” instead of “…” for continuation, as done in python. Answer is yes and no.</p><p>No because you cannot use it as line continuation character but</p><p>Yes you can use it as a block continuation character. Here is how you use it in RF</p><pre>: FOR    ${INDEX}    IN RANGE    1    11<br>\    DoSomething      <br>\    DoSomethingMore</pre><p>In the above example, “\” is used as block continuation character.</p><p>2. <strong>Does it matter if I use &lt;space&gt; or &lt;tab&gt; in calling a keyword.</strong></p><p>Suppose you are implementing a conditional sequence like this…</p><pre><strong>***Testcase***</strong></pre><pre>MenuGoto&lt;tab&gt;Cat1</pre><pre><strong>***Keywords***</strong><br>MenuGoto<br><em>&lt;tab&gt;</em>[Arguments]<em>&lt;tab&gt;</em>${category}</pre><pre>${category} =       Convert To Lowercase    ${category}</pre><pre>RunKeywordAndReturnIf             &#39;${category}&#39; == &#39;cat1&#39;<br>...                 MenuGoto<em>&lt;tab&gt;</em>Cat1</pre><pre>RunKeywordAndReturnIf             &#39;${category}&#39; == &#39;cat2&#39;<br>...                 MenuGoto<em>&lt;tab&gt;</em>Cat2</pre><pre>MenuGoto<em>&lt;space&gt;</em>Cat1<br>   Log Cat1<br>MenuGoto<em>&lt;space&gt;</em>Cat2<br>   Log Cat2</pre><p>And try to run the code, this will result in an error</p><p><strong><em>Maximum limit of started keywords exceeded.</em></strong></p><h4>Why is that so… !!</h4><p>It is because MenuGoto&lt;tab&gt;Cat1 recursively calls MenuGoto&lt;tab&gt;Cat1</p><p>Although we have declared <em>MenuGoto</em><strong><em>&lt;space&gt;</em></strong><em>Cat1; </em>RF is not able to find <em>MenuGoto</em><strong><em>&lt;tab&gt;</em></strong><em>Cat1. </em>So right way to declare this is</p><pre><strong>***Testcase***</strong></pre><pre>MenuGoto<strong>&lt;tab&gt;</strong>Cat1</pre><pre><strong>***Keywords***</strong><br>MenuGoto<br><em>&lt;tab&gt;</em>[Arguments]<em>&lt;tab&gt;</em>${category}</pre><pre>${category} =       Convert To Lowercase    ${category}</pre><pre>RunKeywordAndReturnIf             &#39;${category}&#39; == &#39;cat1&#39;<br>...                 MenuGoto<strong><em>&lt;space&gt;</em></strong>Cat1</pre><pre>RunKeywordAndReturnIf             &#39;${category}&#39; == &#39;cat2&#39;<br>...                 MenuGoto<strong><em>&lt;space&gt;</em></strong>Cat2</pre><pre>MenuGoto<em>&lt;space&gt;</em>Cat1<br>   Log Cat1<br>MenuGoto<em>&lt;space&gt;</em>Cat2<br>   Log Cat2</pre><p>3. Does it matter if I use If Else or IF ELSE</p><p>Generally the answer to this question is that it does not matter. By RF is very specific about its cases…I burnt good few hours and some slack help from RF friends to finally get over this hurdle. Here is what I was trying to do.</p><pre>`Login</pre><pre>[Documentation]<em>     GetMyId . retry 3 times else fail</em></pre><pre><em>FOR</em>    ${i}    <em>IN RANGE</em>    3</pre><pre>${status}=     Run Keyword And Ignore Error    GetMyId</pre><pre>Run Keyword If    &#39;${status}[0]&#39; == &#39;PASS&#39;     Exit For Loop</pre><pre>...     <strong>Else If</strong>    ${i}==2         Fail</pre><pre>Log     After Failure still running</pre><pre><em>END</em></pre><p>To naive user this seems simple enough. So just before exiting we mark Login Keyword to fail. But thats not what you get. Here is the log</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Fu9khDdUxgvuKZwhEjwqQ.png" /></figure><p>As you can see it ran through the loop but never exited as a result of “Pass” or mark test “Fail” as a result of end of loop. Ideally at i==2 this should have failed. After struggling a lot, good friends from RF community suggested using ELSE IF instead of Else If . After doing that this got fixed here are the new logs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P8nvs4DQiQY_1bEAV4GCWg.png" /></figure><p>and new code looks as follows</p><pre>Login</pre><pre>[Documentation]<em>     GetMyId . retry 3 times else fail</em></pre><pre><em>FOR</em>    ${i}    <em>IN RANGE</em>    3</pre><pre>${status}=     Run Keyword And Ignore Error    GetMyId</pre><pre>Run Keyword If    &#39;${status}[0]&#39; == &#39;PASS&#39;     Exit For Loop</pre><pre>...     <strong>ELSE IF</strong>   ${i}==2         Fail</pre><pre>Log     After Failure still running</pre><pre><em>END</em></pre><p>Are there any more Gotchas you have come across. Please let me know…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33300d84a62c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Scrapper for fetching daily Covid-19 numbers in under 20 lines]]></title>
            <link>https://randombites.medium.com/building-scrapper-for-fetching-daily-covid-19-numbers-in-under-20-lines-4a98c48bc263?source=rss-26f78b68074d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a98c48bc263</guid>
            <category><![CDATA[data-scraping]]></category>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[beautifulsoup]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[requests-library]]></category>
            <dc:creator><![CDATA[MP]]></dc:creator>
            <pubDate>Sun, 17 May 2020 14:43:16 GMT</pubDate>
            <atom:updated>2020-05-17T14:45:30.563Z</atom:updated>
            <content:encoded><![CDATA[<p>Building Scrapper for fetching daily Covid-19 numbers in under 20 lines</p><p>Steps to build Covid-19 scrapper</p><p>This is part of series “<a href="https://medium.com/@randombites/towards-building-covid-19-tracker-e7e8f7926f2b">Towards Building Covid 19 Tracker</a>”</p><p>We would like to fetch Covid-19 numbers for India. These numbers can be found over <a href="https://www.mohfw.gov.in/">here</a>(<a href="https://www.mohfw.gov.in/">https://www.mohfw.gov.in/</a>).</p><p>As can be seen from Webpage, numbers are shown under 4 categories</p><ul><li>Active Cases (53946)</li><li>Cured/Discharged (34108)</li><li>Deaths (2872)</li><li>Migrated (1)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YVelyA1ALhIiY4hawKl6qg.png" /><figcaption>Screen capture of Covid-19 India numbers</figcaption></figure><p>For fetching data programmatically we will use python’s library <a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/">BeautifulSoup</a>.</p><p>On Python 3 we can install it as follows</p><pre>pip install BeautifulSoup4</pre><p>Now that we have our environment ready; lets start to investigate the page structure. For this we use chrome’s “inspection” tool. To invoke Chrome tools you can use shortcut (ctrl+shift+I — on windows).</p><p>Relevant Dom Tree is as follows —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*HxX9-zaWfqDKGbkt8903CA.png" /><figcaption>Dom Tree Structure of Covid Cases</figcaption></figure><p>If you notice the DOM Tree above you will notice all the Counts for different categories is under <em>div class=”site-stats-count”. </em>On close observation you will notice each count is split across li element differentiated by specific element classes(<em>bg-blue, bg-green, bg-red, bg-orange</em>). We will use <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors">CSS selector </a>to reach to that element. Complete css selector would look as following</p><pre>.site-stats-count li.bg-blue strong</pre><p>With Beautifulsoup our code will look as follows —</p><pre>active_count = soup.select(&#39;.site-stats-count li.bg-blue strong&#39;)[0].text</pre><p>As can be seen although <em>Beautifulsoup </em>eases off whole process of parsing data from source, it does not download source of page itself. We need to first download source of page using some popular library like <a href="https://requests.readthedocs.io/en/master/">requests</a>. Here is how we will use it</p><pre>requests.get(&#39;https://www.mohfw.gov.in/&#39;).text</pre><p>That’s it output of requests library should then be fed to BeautifulSoup and there we have complete covid-19 india numbers data scraper ready for use.</p><p>Here is complete code</p><pre>`#<em> initialisation</em></pre><pre>india_source = &#39;https://www.mohfw.gov.in/&#39;</pre><pre>#<em> Scrapping</em></pre><pre>#<em> query the website and return the html to the variable ‘page’</em></pre><pre>page = requests.get(india_source)</pre><pre>pgtxt = page.text</pre><pre>#<em> parse the html using beautiful soup and store in variable `soup`</em></pre><pre>soup = BeautifulSoup(pgtxt, &#39;html.parser&#39;)</pre><pre>#<em> Take out the &lt;div&gt; of name and get its value</em></pre><pre>active_count = soup.select(&#39;.site-stats-count li.bg-blue strong&#39;)[0].text</pre><pre>print(f&quot;Active Cases::{active_count}&quot;)</pre><pre>cure_count = soup.select(&#39;.site-stats-count li.bg-green strong&#39;)[0].text</pre><pre>print(f&quot;Cured/Discharged Cases::{cure_count}&quot;)</pre><pre>death_count = soup.select(&#39;.site-stats-count li.bg-red strong&#39;)[0].text</pre><pre>print(f&quot;Deaths Cases::{death_count}&quot;)</pre><pre>migrated_count = soup.select(&#39;.site-stats-count li.bg-orange strong&#39;)[0].text</pre><pre>print(f&quot;Migrated Cases::{migrated_count}&quot;)</pre><p>Once you have data it can then be stored in desired format. I am using csv as it is very handy for later parts.</p><p>Next we will look at different statistical plots and how to draw them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a98c48bc263" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Towards Building Covid 19 Tracker]]></title>
            <link>https://randombites.medium.com/towards-building-covid-19-tracker-e7e8f7926f2b?source=rss-26f78b68074d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7e8f7926f2b</guid>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[india]]></category>
            <dc:creator><![CDATA[MP]]></dc:creator>
            <pubDate>Sun, 17 May 2020 13:26:00 GMT</pubDate>
            <atom:updated>2020-05-20T19:04:30.320Z</atom:updated>
            <content:encoded><![CDATA[<p>My journey towards building Covid-19 tracker for India nos</p><p>Last week I started to write my own covid 19 tracker for India numbers. Inpiration came after I found another tracker over here <a href="https://indiacovid19.github.io/">https://indiacovid19.github.io/</a></p><p>As I was going over the tracker I realised there is so much to learn while building similar tracker. So here is my attempt to learn the skills and implement in a live project. I will try to document my learnings in this series.</p><p>Some of the things I plan to document —</p><p>a. <a href="https://medium.com/@randombites/building-scrapper-for-fetching-daily-covid-19-numbers-in-under-20-lines-4a98c48bc263">Building Scrapper for fetching daily numbers</a></p><p>b. Statistical charts</p><ul><li><a href="https://medium.com/@randombites/daily-percentage-change-90974697c1a0">Daily Percentage Change</a></li><li>Doubling Rate</li><li>Total Cases in Linear Scale</li><li>Total Cases in Logarithmic Scale</li><li>New Cases</li><li>Doubling Time</li><li>Cured Percent</li><li>Cured Ratio</li></ul><p>c. Automating whole process for daily scrapping and charting</p><p>If there are more things to share I will append to this list</p><p>Lets get started with <a href="https://medium.com/@randombites/building-scrapper-for-fetching-daily-covid-19-numbers-in-under-20-lines-4a98c48bc263"><em>Building Scrapper for fetching daily numbers</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7e8f7926f2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Timeseries chart with Mathplotlib]]></title>
            <link>https://randombites.medium.com/timeseries-chart-with-mathplotlib-ef2cae901059?source=rss-26f78b68074d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef2cae901059</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[matplotlib]]></category>
            <category><![CDATA[pandas]]></category>
            <dc:creator><![CDATA[MP]]></dc:creator>
            <pubDate>Sun, 17 May 2020 11:33:14 GMT</pubDate>
            <atom:updated>2020-05-17T11:33:14.879Z</atom:updated>
            <content:encoded><![CDATA[<h3>Basic Timeseries chart with Mathplotlib</h3><p>Last week I started to generate my own covid 19 tracker using python. I will write separately on the journey, here we will focus on problem that I faced to generate timeseries chart with Mathplotlib.</p><p>For the tracker I started to download data everyday with the simple scrapper I wrote by myself.</p><p>The data looks like this …</p><blockquote><strong>date,active_count,cure_count,<em>death_count,</em>migrated,source</strong></blockquote><blockquote>12/05/20 07:35:04,46008,22454,<em>2293,</em>1,https://www.mohfw.gov.in/</blockquote><blockquote>13/05/20 08:56:46,47480,24385,<em>2415,</em>1,https://www.mohfw.gov.in/</blockquote><blockquote>14/05/20 14:10:50,49219,26234,<em>2549,</em>1,https://www.mohfw.gov.in/</blockquote><p>As you can see its a timeseries data which seems simple to plot.</p><p>So I read in the data with pandas read_csv api as follows</p><pre>self.dataf = pd.read_csv(“covid_india.csv”, parse_dates=True)</pre><p>And plotted as follows self.dataf.plot()</p><p>This gives us following plot</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*X4eoUHRfmT_QZuVCJ5zlOg.png" /><figcaption>Plain plot of dataframe</figcaption></figure><p>You will notice x axis does not show dates, which is desirable for clarity.</p><p>Plain plot does not help that means we need to break the dataframe to separate date series and remaining dataframe (data points).</p><p>Here is how new code looks like</p><pre><em>import</em> matplotlib.pyplot <em>as</em> plt<br># self.dataf.iloc[:,1:-1] returns 1 to last col dataframe<br># self.dataf[&#39;date&#39;] returns date series</pre><pre>plt.plot(self.dataf[&#39;date&#39;],self.dataf.iloc[:,1:-1])</pre><p>But this will fail as ‘date’ column has date as first part while year last part and panda does not know about this.</p><p>So we provide panda this information</p><pre>pd.to_datetime(self.dataf[‘date’], dayfirst=True)</pre><p>so overall code looks like this</p><pre><em>import</em> matplotlib.pyplot <em>as</em> plt</pre><pre>plt.plot(pd.to_datetime(self.dataf[&#39;date&#39;], dayfirst=True).dt.date,self.dataf.iloc[:,1:-1])<br>plt.show()</pre><p>The plot looks as follows —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vz9skHuI1y4JQyAkfnXWIg.png" /></figure><p>We will look at advanced timeseries usecase when I show Daily Percentage Change code.</p><p>Did you have a better way let me know, i would like to know</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef2cae901059" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running log of Mysql Snippets]]></title>
            <link>https://randombites.medium.com/running-log-of-mysql-snippets-f462b05adefb?source=rss-26f78b68074d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f462b05adefb</guid>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[MP]]></dc:creator>
            <pubDate>Tue, 08 Oct 2019 05:49:20 GMT</pubDate>
            <atom:updated>2019-10-08T05:49:20.683Z</atom:updated>
            <content:encoded><![CDATA[<p>This will be my running log of Mysql snippets.</p><p><strong>Snippet 1: </strong>How to Get values of a row at given index</p><p>When you know row index but can’t rely on autoincremented value. This is how you do</p><pre>select * from myTable Limit 10, 1<br><em>(where 10 is the row index-1 and 1 is number of rows after that.</em> <em>Note: -1 since </em><strong><em>0-based </em></strong><em>index)</em></pre><p><em>Reference:</em> <a href="https://stackoverflow.com/questions/10457458/select-specific-row-from-mysql-table"><em>https://stackoverflow.com/questions/10457458/select-specific-row-from-mysql-table</em></a></p><p><strong>Snippet 2:</strong> Conditional statements</p><p>If you have a need to do some actions based on conditions you can do that as follows</p><pre>select * from docs where id = (<br>  SELECT (case when <br>          ( <br>            (select count(id) from docs)%2=0<br>          ) <br>   THEN<br>      (select count(id) DIV 2 from docs)<br>   ELSE<br>      (select 1+count(id) DIV 2 from docs)<br>   END)<br> );<br><em>(Here we are doing actions based on count being odd or even)</em></pre><p><em>Reference:</em> <a href="https://stackoverflow.com/questions/8763310/how-do-write-if-else-statement-in-a-mysql-query"><em>https://stackoverflow.com/questions/8763310/how-do-write-if-else-statement-in-a-mysql-query</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f462b05adefb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cmder — Not Enough Space]]></title>
            <link>https://randombites.medium.com/cmder-not-enough-space-8c6a7e0dd640?source=rss-26f78b68074d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c6a7e0dd640</guid>
            <category><![CDATA[ssh]]></category>
            <dc:creator><![CDATA[MP]]></dc:creator>
            <pubDate>Tue, 07 May 2019 09:19:45 GMT</pubDate>
            <atom:updated>2019-05-07T09:19:45.401Z</atom:updated>
            <content:encoded><![CDATA[<h3>Cmder — Not Enough Space</h3><p>So I started using Cmder few weeks back after switching from conemu its parent version.</p><p>The main reason for using Cmder was to use the awesome bash tools with it.</p><p>As I started using ssh to connect to remote server via tunneling I started to hit this weird error “Not Enough Space”. Since single server connection by ssh was fine, it was even more perplexing why proxycommand was not working.</p><p>But soon I realised the error was related to using wrong ssh. I have two version of ssh, one that came with gitbash and another installed in windows/system32</p><p>Cmder was refering to windows/system32 via an entry in path.</p><p>After removing that entry from path, magically all problems were gone</p><p>So if someone else hits this problem it is most likely related to the ssh executable where it is installed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c6a7e0dd640" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to scroll while waiting for an element]]></title>
            <link>https://randombites.medium.com/how-to-scroll-while-waiting-for-an-element-20208f65b576?source=rss-26f78b68074d------2</link>
            <guid isPermaLink="false">https://medium.com/p/20208f65b576</guid>
            <category><![CDATA[selenium]]></category>
            <category><![CDATA[appium]]></category>
            <category><![CDATA[selenium-webdriver]]></category>
            <category><![CDATA[automation-testing]]></category>
            <dc:creator><![CDATA[MP]]></dc:creator>
            <pubDate>Fri, 26 Oct 2018 12:42:34 GMT</pubDate>
            <atom:updated>2018-10-26T12:42:34.005Z</atom:updated>
            <content:encoded><![CDATA[<p>How do you verify element is present on the page while it is in nonvisible area of the page</p><p>Typically when doing Mobile automation, one would try to wait for an element on a page in visible area.</p><p>For this we would use wait.util alongside expected conditions as <a href="https://www.seleniumhq.org/docs/04_webdriver_advanced.jsp">follows</a></p><pre><strong>from</strong> <strong>selenium.webdriver.support</strong> <strong>import</strong> expected_conditions <strong>as</strong> EC<br>wait = WebDriverWait(driver, <strong>10</strong>)<br>element = wait.until(EC.element_to_be_clickable((By.ID,&#39;someid&#39;)))</pre><p>But, on mobile device screen size is limited and there are chances some elements are present somewhere down in the nonvisible area. In this case we need to scroll to that element which cannot happen while we are waiting.</p><p>What typically one needs to do in this scenario is to write a wait loop with max timeout and scroll down the page while checking for element.</p><p>This works but is suboptimal. Instead of that Wait.util provides a possibility to write custom waits.</p><p>To implement custom wait one needs to write custom Expected condition. A custom wait condition can be created using a class with __call__ method which returns False when the condition doesn’t match.</p><p>For our requirement we need to write as follows —</p><pre>class element_present_after_scrolling(object):<br>    &quot;&quot;&quot;An expectation for checking that an element is present<br>    locator - used to find the element<br>    returns the WebElement once it has the particular element<br>    &quot;&quot;&quot;<br>def __init__(self, locator, driver):<br>    self.locator = locator<br>    self.driver = driver</pre><pre>def __call__(self, driver):<br>    self.driver._debug(&quot;element_present_after_scrolling::Finding Elements&quot;)<br>    elements = driver.find_elements(*self.locator)   # Finding the referenced element<br>    if len(elements) &gt; 0:<br>        return elements<br>    else:<br>        self.driver.swipe_by_percent(50,90,50,10)</pre><p>In the above example we are swiping the screen up to check for presence of element.</p><p>In the wait.until we would be using this new expected condition as follows —</p><pre>elements = wait.until(element_present_after_scrolling((By.XPATH, xpath), driver))</pre><p>Now when you run this code the page will start scrolling if the element is not found in nonvisible area</p><p>Happy Coding!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20208f65b576" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Test Automation: Zoom In on Mobile]]></title>
            <link>https://randombites.medium.com/test-automation-zoom-out-on-mobile-c30ae1039a04?source=rss-26f78b68074d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c30ae1039a04</guid>
            <category><![CDATA[mobile-test-automation]]></category>
            <category><![CDATA[multi-touch]]></category>
            <category><![CDATA[appium]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[selenium-test-automation]]></category>
            <dc:creator><![CDATA[MP]]></dc:creator>
            <pubDate>Mon, 17 Sep 2018 10:38:48 GMT</pubDate>
            <atom:updated>2018-09-17T10:50:03.620Z</atom:updated>
            <content:encoded><![CDATA[<p>How to perform Zoom In on Mobile</p><p>Today I had to implement zoom in on Mobile. I will be using Appium, iOS and Python binding. But the concepts should be similar on other platforms.</p><p>In order to implement ZoomIn one needs to use touch action commands. In particular MultiAction Api.</p><p>Here is how zoom In works in theory —</p><pre>1. Create Touch Action for finger moving up<br>2. Create Touch Action for finger moving down<br>3. Chain the touch actions to perform MultiAction</pre><p>Sounds simple isn’t it. Here is the documentation related to Appium <a href="http://appium.io/docs/en/commands/interactions/touch/multi-touch-perform/">docs</a></p><p>The example there are self explanatory.</p><p>Here is one such example —</p><pre># Up finger<br>a1 = TouchAction()<br>a1.press(None, startX, startY)<br>a1.move_to(None, xUp, yUp)<br>a1.release()</pre><pre># Down finger<br>a2 = TouchAction()<br>a2.press(None, startX, startY)<br>a2.move_to(None, xDown, yDown)<br>a2.release()</pre><pre>#Chaining the Actions<br>ma = MultiAction(driver)<br>ma.add(a1, a2)<br>ma.perform()</pre><p>Note Up and Down fingers start at same location startX &amp; startY</p><p>But it fails to mention something very crucial which I discovered while implementing it.</p><p>Between the press and move one has to introduce delay as only then the element responds to multiperform . So here is the modified version</p><pre># python<br># Up finger<br>a1 = TouchAction()<br>a1.press(None, startX, startY)<br><strong><em>a1.wait(ms=450)</em></strong><br>a1.move_to(None, xUp, yUp)<br>a1.release()</pre><pre># Down finger<br>a2 = TouchAction()<br>a2.press(None, startX, startY)<br><strong><em>a2.wait(ms=450)</em></strong><br>a2.move_to(None, xDown, yDown)<br>a2.release()</pre><pre>#Chaining the Actions<br>ma = MultiAction(driver)<br>ma.add(a1, a2)<br>ma.perform()</pre><p>Thats it!!</p><p>Happy Coding!</p><p><em>If this helped you in your work, do tell me</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c30ae1039a04" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>