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
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 😉
Vienna says
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.
Mukesh Otwani says
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
Vienna says
Thank you for your reply. Hope to see new contents from you. Wish you all the best.
carlo mario says
cuanto te sale uStaleElementReferencen que puedes teniendo en cuenta que los wait no me corrige este error
Mukesh Otwani says
Hi Carlo,
Kindly comment in english so that other readers can also understand your requirement
vinod singh says
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.
Mukesh Otwani says
Hi Vinod,
I am happy to read from you.
charan says
How we can automate the browsers which are opening via citix ?
Mukesh Otwani says
No I guess 🙁
Prabhu says
Thank you so much Mukesh! Your post is simply awesome!!
Mukesh Otwani says
Thanks Prabhu. I am glad you liked the post.
MIrza says
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.
Mukesh Otwani says
Hi Mirza,
You can use Sikuli also in this case.
veer singh says
hi sir thanks
Mukesh Otwani says
Your welcone Veer
Mike says
Hello, have you ever faced with that problem “Vector smash protection is enabled.”. And how to handle with that one
Mukesh Otwani says
Hi Mike,
I never faced above issue 🙁 this is completely new for me.
Akshatha says
Hi,
Can u please share custom methods u created to avoid sync issues and timeouts.
Thank you.
Mukesh Otwani says
Hi Akshatha,
will update sync method soon.
Hakan Uzunkaya says
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”);
}
Mukesh Otwani says
Hi Hakan,
True I totally agree that we should have log feature in our script to keep track of our execution.
Thanks
pavankumar says
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
Mukesh Otwani says
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
pavankumar says
Is it possible to share the custom method which you have created
Mukesh Otwani says
Hi Pavan will share soon..
Satnam Singh says
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.
Mukesh Otwani says
Thanks Satnam