Skip to main content

#HACKMONDAY – Debugging my first UI Automation Test Sample (PART I)


How to debug your first UI Automation Test Sample




Another One! (DJ Khaled’s Voice). That’s RIIGGHHT; I am back! I wanted to do my first #HackMonday to follow up on my WinAppDriver (WAD) post. This a three-part blog. In part I of the blog, I will debug the Python calculator sample test. In part II of the blog, I will debug my own Python WordPad test.

Background info:

#HackMonday is an idea I came up with as a social experiment. The goal is to #hack with someone new, with the hopes of learning or teaching them something new. For this #HackMonday, I had the pleasure of virtually meeting Hammid Funsho (HI FWEND!)

About Hammid:





A little bit about Hammid, He is a software engineer. He has about 12 years of experience under his belt. He has a passion for automation testing. He codes Java, but occasionally dabbles in Python, and Ruby.  Hammid is currently based out Raleigh North Carolina.

How did I come about meeting Hammid? Great question! It’s simple; I met Hammid on twitter. I saw his profile and liked his software creds, so I asked him if he would be interested in being part of my first #hackmonday. Thankfully, Hammid gracefully accepted my invitation to #hack.











Pre-Requisite:



2.Windows 10 machine



5. Patience



I started off by explaining WinAppDriver to Hammid since he wasn’t familiar with it. (For a recap, click here). Before we debugged my Python Wordpad UI test, I decided to show him WinAppDriver (WAD) in all its glory by running the Python Calculator Test for WAD. The calculator test was a functioning test and should have been an easy way to showcase WAD. To my surprise, the test failed. I must admit, I was taken back by the results since I ran this a couple of weeks ago. I knew for a fact I had not made any changes to the code since I downloaded it from GitHub. So with our best Tom Cruise impressions, Hammid and I went on mission impossible to figure out what went wrong. We started off by comparing the copy of the calculator test I had to the one on the WAD GitHub. We found no differences.



We checked the WAD logged, and we found no 400 errors either. We decided to go back to Visual Studio Code and look at the traceback in the Debug Console.














Here is a video of us debugging the calculator test.

While reviewing the traceback in the debug console, we kept seeing Assertion Error: ‘Display is 8’ != ‘Display is  8 ‘ which means “display is 8 is not equal to display is  8 ”. 




Side note
At first glance, you may not notice anything wrong with the error messages. So we decided to use the print technique to understand what the CalculatorResults value should be.   


def test_initialize(self):
        self.driver.find_element_by_name("Clear").click()
        self.driver.find_element_by_name("Seven").click()


        result = self.driver.find_element_by_accessibility_id("CalculatorResults")

        print (result.text)

        self.assertEqual(str(result.text),"Display is  7 ")


We ran the code and saw that the CalculatorResults value is "Display is 7" but our code was still failing.However, if you look closer, there are some extra white spaces included in one of the “Display is 8”. This was odd since I had not made any changes to the calculator test. To further investigate the issue, we opened up the windows app called Inspect which enables you to view the UI element and see its attributes/ accessibility information.





Upon further inspection, we agreed that there were too many white spaces for "Display is 8" in the calculatortest.py test. So after checking Inspect and verifying this ourselves, we decided to remove the extra white spaces. We reran the test again and this time  S-U-C-C-E-S-S.




Conclusion:




The sudden change in the element “calculatortest” I believe was due to a Windows update that I did on my machine the day prior.  The calculator app must have updated, and the dev team must have removed the extra white spaces which in turn broke the calculatortest.py code.  I learned a lesson. Your environment is always changing, and I find myself asking how could I improve this code so that if there are any additional updates, my code will not break. We could potentially use the strip method or the replace method in python. You can check out an article on how to strip characters from a string from the website below.
























Comments

  1. Thanks for the useful information of software testing courses, give more updates on software testing development, First time I visit your blog really nice, I bookmark your blog here after a daily visit. Learn software testing course in Chennai

    ReplyDelete
  2. I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here.Thanks once more for all the details.
    Best selenium training Institute in chennai

    ReplyDelete
  3. I feel extremely cheerful to have seen your web page and anticipate such a large number of additionally engaging circumstances perusing here.Thanks yet again for every one of the points of interest.
    Read Beard Press

    ReplyDelete
  4. Yiioverflow presenting one of the best and high performance PHP framework. Fast, secure and extremely professionals are developing applications. We guide to implement mobile app development and SOA hybrid applications.Code in Nodejs, Angular,Ionic,ReactJS and Yiiframework.

    ReplyDelete
  5. Thanks for sharing the valuable information to share with us For more valuable information please visit our website.

    selenium training in chennai


    aws training in chennai

    ReplyDelete
  6. Excellent blog about Python. I learned a lot from your blog and I have bookmarked this page for my future reference. Keep up the good work and share more like this.
    Python Classes in Chennai | Python Training

    ReplyDelete
  7. Your posts are the flower of the flock. I apply the advice in real life. They contain pieces of advice. I'm grateful for your sharing. I hope you will write often and post more articles.
    email with love 2018 email with love 2018

    ReplyDelete
  8. Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..Keep update more information..

    selenium training in bangalore

    aws training in bangalore

    ReplyDelete
  9. The blog you have shared is very much helpful to know more about the selenium. Thanks for your information about the selenium.
    selenium testing training
    selenium testing course
    selenium training classes
    selenium classes
    selenium training course

    ReplyDelete
  10. This concept is a good way to enhance the knowledge.thanks for sharing. please keep it up selenium Online Training Hyderabad

    ReplyDelete
  11. This concept is a good way to enhance the knowledge.thanks for sharing. please keep it up selenium Online Training Hyderabad

    ReplyDelete
  12. You won't believe me, but I was planning to write a blog very similar to the one you have posted here. Great work!

    Python Training In Chennai

    Selenium Training In Chennai

    ReplyDelete
  13. A very useful blog to every. Really it is easy to understand.
    Great job. Keep posting the updates.
    selenium training
    selenium course
    selenium testing training

    ReplyDelete
  14. Thank you for sharing such a nice and interesting blog with us. Hope it might be much useful for us. keep on updating...!!

    Article submission sites
    Guest posting sites

    ReplyDelete
  15. If you want to play like me and not lose, you should try playing BGAOC. free gambling with us Playing here you not only win but also get a lot of fun.

    ReplyDelete
  16. This comment has been removed by the author.

    ReplyDelete
  17. I feel satisfied to read your blog, you have been delivering a useful & unique information to our vision.keep blogging.
    salesforce Training in Bangalore
    uipath Training in Bangalore
    blueprism Training in Bangalore

    ReplyDelete
  18. Good post!Thank you so much for sharing this lovely article.It was so good to read and useful to upgrade my understanding...
    salesforce Training in Bangalore
    uipath Training in Bangalore
    blueprism Training in Bangalore

    ReplyDelete
  19. I have been reading for the past two days about your blogs and topics, still on fetching! Wondering about your words on each line was massively effective. Techno-based information has been fetched in each of your topics. Sure it will enhance and fill the queries of the public needs. Feeling so glad about your article. Thanks…!
    best software testing training in chennai
    best software testing training institute in chennai with placement
    software testing training
    courses

    software testing training and placement
    software testing training online
    software testing class
    software testing classes in chennai
    best software testing courses in chennai
    automation testing courses in chennai

    ReplyDelete

  20. You write this post very carefully I think, which is easily understandable to me. Not only this, but another post is also good. As a newbie, this info is really helpful for me. Thanks to you.
    Tally ERP 9 Training
    tally classes
    Tally Training institute in Chennai
    Tally course in Chennai

    ReplyDelete

Post a Comment

Popular posts from this blog

Are You a New Programmer and Would Like to Test Your Windows Application or Existing Windows Application? Here Is a Guide to Help You Get Started. (The Beginner’s Edition)

Getting You Started with WinAppDriver


Are you a total beginner to programming just like I am, but you would still like to try out Microsoft’s tool for application testing? Well don’t worry, I got you covered. Below I will detail my experience with getting started with WinAppDriver and testing basic Windows application such as the calculator in Python and C#. This tool could be beneficial for developers that would like to test their software before production or launch. The purpose of this tutorial is to create easy steps to follow and enable you to use WinAppDriver. I once read a quote that says:
“If you want to learn something, read about it. If you want to understand something, write about it. If you want to master something, teach it.”                                                                                                                                             - Yogi Bhajan

So here goes nothing 😊


Getting Started: What is the Windows Application Driver?
Windows Applicat…

#HACKMONDAY - Debugging my first UI Automation Test Sample (PART II)

Hi Y'all, thanks for stick around for part II. If you landed here by accident, you might want to stick around; this may get interesting. In part II of this blog, we will start to debug my python WordPad test for WAD. It’s exciting to me because back when I wrote this test, all I had was a dream, a notebook, a pencil, a computer, and Google.

Fellow Hacker: Hammid Funsho

I am still hacking with Hammid for part II.

So let’s get to it.


A quick description of what the WordPad test does. For starters,
We start off with the function Def setUP and Def tearDown. These two functions are in charge of opening the WordPad app and initializing the webdriver. Most automation test will have functions that resemble these at the beginning.Then we have my test functions. Each of the tests function examines a unique aspect of the WordPad app. Function test_write sends keys to the text box. Function test_initialize looks at the title bar and makes sure WordPad is opened up with a ‘clean’ window. Functio…