Java automation is not a simple task and developers have to put maximum efforts to automate any Java application. In this article, we will discuss some problem solving approaches to help you with Java automation using basic Java concepts.
- Robot classes
- Reflection Technique
- Code injection
Robot classes to automate Java
Robot is one of the typical Java classes for stimulating keyboard events. The best part is that Robot classes can be used to automate almost any application. The application can be automated if –
- Screen solutions on all desktops is same
- Each application has same height and width
- Co-ordinate value should be same in all possible scenarios.
- Multitasking should not be performed when running robot class automation technique
This is usually considered as imperfect automation technique as it is not good for stimulating UI. Developers have to go inside Java code to access required objects and continue with desired operations. Then how can we access third party objects? The next two automation techniques solve the problem considerably.
Reflection automation Technique
Reflection technique is a good automation technique for UI component objects but it is not good for automating applet apps. It is true that applet works on dynamic parameters and very complex to understand. When dimensions are not fixed, it becomes hard for developers to automate any application.
This is most suited approach where code can be migrated from one machine to other without changing its basic information and coding standards. Here it is assumed that third party application is already running and code injected into it directly.
There are two possible techniques for code injection – Java instrumentation and instrumentation agent. Developers have to know how to use these techniques to automate Java applications using core Java.
Here, we have discussed best automation techniques suitable for almost any Java web application. From the discussion, it is clear that code injection is most suited approach for Java automation. However, you have to face hurdles during implementation but experience and practice will overcome the problems.