• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Programming Languages
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials
  • Automation Tools and Different Tools
    • Web Automation
      • Selenium with Java
        • Selenium Basic
        • Selenium Advance
        • Selenium Realtime
        • Framework
        • Selenium Interview
        • Selenium Videos
        • Selenium with Docker
      • Selenium with Python
      • WebdriverIO
        • Selenium Webdriver C# Tutorial
      • Cypress
      • Playwright
    • TestNG
    • Cucumber
    • Mobile Automation
      • Appium
    • API Testing
      • Postman
      • Rest Assured
      • SOAPUI
    • testRigor
    • Katalon
    • TestProject
    • Serenity BDD
    • Gradle- Build Tool
    • RPA-UiPath
    • Protractor
    • Windows Automation
  • Automation For Manual Testers
  • Services
  • Online Training
  • Contact us
  • About me
  • Follow us
    • Linkedin
    • Facebook Group
    • Facebook Page
    • Instagram

Automation

Selenium WebDriver tutorial Step by Step

You are here: Home / Automation Concepts / Pain of an Automation Engg and Best practices to avoid

Pain of an Automation Engg and Best practices to avoid

November 1, 2015 by Mukesh Otwani 27 Comments

Automation best practices

Pain of an automation engineer

If you are working with any automation tool then you can relate this term OR if you are starting with Automation testing then be ready with this pain.

When I started with automation testing I was going through this stage and I used to think that why I am not able to write good automation scripts, why my automation script is not stable.

I have  listed down what used to happen with me and how I overcome through this.

When I used to create automation script

  • My script used to work fine sometimes and sometimes it used to fail.
  • When I run the script in my local machine it works fine but when I run in remote or another browser it fails.
  • Scripts work fine in one browser and it fails in other browsers.
  • Scripts work fine for current release, but it fails when new release come for my applications.
  • Earlier I used to create scripts without any framework so even if small changes in the application then I used to make the changes in each script.

 

Story-  I would like to tell you a scenario that happens with almost everyone. I created some sample script for my application and executed in all browser and next day when I was about to show the demo it failed due to some locator issue and when I came back to my desk and executed the same test cases it got passed.

This was the repeated scenario for me and finally I followed some best practices and got very good results.

 

Best practice to overcome this pain.

I will list down mainly for Selenium, but you can follow for other tools as well.

 

Stat writing your own xpath using xpath methods

I used to copy the default xpath generated by firebug and file path and was using in my script. It takes less time but trust me this xpath will not help you in the long run.

Find some pattern in element and write your own Xpath. Follow below link for xpath

Dynamic xpath in Selenium

 

Start using a design/framework

You can directly start writing your automation script without any framework that fine but maintenance task will be a big headache once test case size will grow even if a small change in the application then you have to modify all script.

You can start using any framework, but it should have below characteristic.

  • Reusable 2- Easy to use    2- Easy to maintain      4- Robust in nature

 

         

Most important

Execute your script multiple times 

 It sounds crazy but trust me it will stable your script and you will get to know what’s your script behavior.

I will tell you my scenario which I follow in my organization and will highly suggest to all of you to follow if suites you.

I execute each script almost 10 times and check how the history is. If script pass ratio is 80 % then you are on the right path but still you need to find out why it failed 2 times. If you ignore this failure then trust me in future your script will fail again due to the same reason. So have a look to that failure and fix it permanently.

If you do want to execute the script manually then take help of Jenkins and schedule it for every one hour or 30 minutes.

Selenium Integration with Jenkins and Schedule your test

It may take some time but your script will be highly stable and you will get good ROI from your script.

 

Use Smart wait in your script

Selenium and I guess all automation tools having some smart wait which will allow you to wait for an element.

90 % automation script failure reason is Sync issue and locator changes only.

 

I have followed above best practices but if you have some more suggestion or any practice that you have followed then please let me know I will add in this post.

Please share with your friends who also facing this pain 😉

 

 

 

 

 

 

Filed Under: Automation Concepts Tagged With: Best tips and practices for Automation testing

Reader Interactions

Comments

  1. Vienna says

    December 26, 2021 at 3:14 AM

    Hi Mukesh,

    Thanks a lot for your post. That’s all helpful practices to follow.

    I’m just a beginner in this field, so I don’t really understand why we should create our own xpath instead of using xpath provided by Chrome ( I use Chrome driver for testing purposes).

    Hope to hear from you. Thank you.

    Reply
    • Mukesh Otwani says

      January 3, 2022 at 5:15 PM

      Hi Vienna,

      Own XPath, I would rather say it as Relative XPath. Based on application UI and textual changes, you can create your own XPath which I think remains more stable than what Chrome provides while inspecting an element because Chrome provides Absolute XPath which are very lengthy and very unstable if application is under development

      Reply
      • Vienna says

        January 10, 2022 at 2:10 AM

        Thank you for your reply. Hope to see new contents from you. Wish you all the best.

        Reply
  2. carlo mario says

    September 13, 2019 at 2:07 AM

    cuanto te sale uStaleElementReferencen que puedes teniendo en cuenta que los wait no me corrige este error

    Reply
    • Mukesh Otwani says

      September 13, 2019 at 1:44 PM

      Hi Carlo,

      Kindly comment in english so that other readers can also understand your requirement

      Reply
  3. vinod singh says

    January 30, 2017 at 5:07 PM

    Hi Mukesh,

    I am a beginner for Selenium webDriver. this post will help lot for me to explore my automation skills.
    thank you so much.

    Reply
    • Mukesh Otwani says

      January 30, 2017 at 5:08 PM

      Hi Vinod,

      I am happy to read from you.

      Reply
  4. charan says

    November 25, 2016 at 12:55 PM

    How we can automate the browsers which are opening via citix ?

    Reply
    • Mukesh Otwani says

      November 25, 2016 at 2:52 PM

      No I guess 🙁

      Reply
  5. Prabhu says

    October 26, 2016 at 6:57 PM

    Thank you so much Mukesh! Your post is simply awesome!!

    Reply
    • Mukesh Otwani says

      November 4, 2016 at 10:43 PM

      Thanks Prabhu. I am glad you liked the post.

      Reply
  6. MIrza says

    August 23, 2016 at 2:24 PM

    Hey,
    I have one scenario where i have to upload the file .but i don’t want to upload file using Auto It or Robot class.Is there any way to keep this file in eclipse and upload this file from eclipse .And in our eclipse only browse button available .When i click on that button it redirect to windows .
    But my requirement is to send this project exe to my client .So what should i do now.

    Reply
    • Mukesh Otwani says

      August 27, 2016 at 11:22 PM

      Hi Mirza,

      You can use Sikuli also in this case.

      Reply
  7. veer singh says

    June 5, 2016 at 12:23 PM

    hi sir thanks

    Reply
    • Mukesh Otwani says

      June 9, 2016 at 2:03 AM

      Your welcone Veer

      Reply
  8. Mike says

    March 6, 2016 at 3:27 AM

    Hello, have you ever faced with that problem “Vector smash protection is enabled.”. And how to handle with that one

    Reply
    • Mukesh Otwani says

      March 7, 2016 at 10:52 AM

      Hi Mike,

      I never faced above issue 🙁 this is completely new for me.

      Reply
  9. Akshatha says

    February 15, 2016 at 11:34 AM

    Hi,
    Can u please share custom methods u created to avoid sync issues and timeouts.

    Thank you.

    Reply
    • Mukesh Otwani says

      February 22, 2016 at 5:21 PM

      Hi Akshatha,

      will update sync method soon.

      Reply
  10. Hakan Uzunkaya says

    November 26, 2015 at 4:37 PM

    Hi Mukesh ,

    Thanks for sharing your experiences,

    Maybe it is worth to add your list that sometimes it is hard to find that where the script fail , which step did not work and so on. Taking screen shot can be a solution but sometimes it is not enough.

    My solution is that adding basic console logs before and after of each methods.

    When you check console directly , you can easily figure out which method is not completed so you can earn time 🙂

    As an example ;

    public void login(….)
    {
    System.out.println(“Login started”);

    //Codes here

    System.out.println(“Login finished”);
    }

    Reply
    • Mukesh Otwani says

      November 27, 2015 at 3:14 PM

      Hi Hakan,

      True I totally agree that we should have log feature in our script to keep track of our execution.

      Thanks

      Reply
  11. pavankumar says

    November 2, 2015 at 4:01 PM

    Mukesh,

    Me also faced this kind of hickups with selenium. Many times i faced no such element exception due to nonsync. Is this good to use Expected conditons for sync. Please advise me

    Reply
    • Mukesh Otwani says

      November 3, 2015 at 9:43 AM

      Hi Pavan,

      We use explicit wait and fluent wait to avoid sync issues. We also created our own method to avoid this and now we have very stable scripts.

      Thanks
      Mukesh

      Reply
      • pavankumar says

        November 3, 2015 at 8:18 PM

        Is it possible to share the custom method which you have created

        Reply
        • Mukesh Otwani says

          November 4, 2015 at 1:28 AM

          Hi Pavan will share soon..

          Reply
  12. Satnam Singh says

    November 1, 2015 at 7:09 PM

    Thanks for sharing this (PAIN OF AN AUTOMATION ENGG AND BEST PRACTICES TO AVOID) Indeed a biggest challenge for automation projects have been well pointed out in your post.

    Reply
    • Mukesh Otwani says

      November 2, 2015 at 1:33 AM

      Thanks Satnam

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Free Selenium Videos

https://www.youtube.com/watch?v=w_iPCT1ETO4

Search topic

Top Posts & Pages

  • Selenium Webdriver tutorial for beginners
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Selenium Webdriver C# Tutorial
  • WHAT ARE YOUR EXPECTATIONS FROM US?

Stay connected via Facebook

Stay connected via Facebook

Archives

Footer

Categories

Recent Post

  • API Testing Using Postman And RestAssured
  • Disable Personalise Your Web Experience Microsoft Edge Prompt In Selenium
  • How To Fix Error: No tests found In Playwright
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Best and easy way to Group test cases in selenium

Top Posts & Pages

  • Selenium Webdriver tutorial for beginners
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Selenium Webdriver C# Tutorial
  • WHAT ARE YOUR EXPECTATIONS FROM US?