A new version of Qualitia Automation Studio for Web and Mobile 7.2.x is now available. We highly recommend you upgrade. Find more details here.
Implementing Custom Actions in Eclipse
In order to create actions in Eclipse, follow the below steps:
- Create a Java project in Eclipse.
- Add the references of Selenium Core Engine in the project. The reference is present at the Qualitia Installation location: %localappdata%\QualitiaWDClient\app-5.0.0\WebDriver.
- To set the reference, right-click Project.
- On Properties select Java Build Path.
- Select Libraries and click Add External Class Folder.
- Add the references of Selenium Java Client Jar from the location Selenium-Server-Standalone-x.xx.x.jar
You can refer to the Key SServerPath set in Qualitia.exe.config. - Add the references of junit.jar from the location %localappdata%\QualitiaWDClient\app-5.0.0\WebDriver\lib\junit-x.x.x.jar.
- Add the reference for log4j-x.x.xx.jar from the location %localappdata%\QualitiaWDClient\app-5.0.0\WebDriver\lib\log4j-x.x.xx.jar
- Add the reference mysql-connector-java-x.x.x-bin.jar from the location %localappdata%\QualitiaWDClient\app-5.0.0\WebDriver\lib\mysql-connector-java-x.x.x-bin.jar.
- Create Java packages and classes in Eclipse.
For example, the class CustomWebEdit is created in the package Custom.CustomObjects.
If the actions are being executed directly on an object, for example, Click, Select, SetValue, SetFocus, then the first parameter of the action needs to be of the class ObjectInfo.
Once the references of Selenium Core Engine are added, the required libraries can be imported into the Custom class.
For example, the Object Info class is imported in the CustomWebEdit class. The Class extends from the existing WebEdit action class.
- The Custom Actions must extend from an existing class only if a customized action is required to be performed on the existing object.
- If a new object is created which is not present in Qualitia, for example, WebLabel, then its class must extend from WebObject.
Â
Develop Actions as follows:
a) Â Write the complete function.
For example, a function CustomSetValue takes two arguments. The first argument is ObjectInfo as this will directly perform the action on the edit box object. The second argument is of the type String which is the value that needs to be set in the edit box. The Custom Action returns an integer value.
If the action does not interact with any object then ObjectInfo parameter is not required.
For example: public int CompareString (String str1, String str2)Â
b) Â Define the function.
To write the function:
- The DataLogger class contains static methods which log messages in the html reports that are generated. This class is present in the package com\webdriverfw\Libraries
When an action is to be performed on an object, the object existence can be checked using exist () function. This function can be used by extending WebObject class in the package com\webdriverfw\Wrappers or an existing relevant action class in the package com\webdriverfw\Wrappers.
The Custom action class must extend from an existing action Object class only if some new customized action is required to be performed on the existing object.Â
Once the actions are completed and compiled successfully, you can create a jar file of the Eclipse project or use the files as it is.
Set the path of the compiled class files/jar files in the Qualitia config UI in the key CustomAction Repository Path. Multiple paths can be set using semi colon (;)Â as the path separator. If a jar file is being used then the path needs to be specified with the complete path including the name of the jar file. If only class files are being used then the path till the base folder of the class needs to be specified. If the classes or projects are referencing any third party jar files, the complete path of the jar files needs to be specified as well. Make sure that the path ends with a semi colon (;).