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
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.
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 😉