In this article, I would like to show how I have implemented my Keyword driven framework using Selenium-WebDriver for automated localization testing of a web based application.
Localization Testing can be defined as a process of customizing a software application to support any language. In localization, native language string is translated to target language & software GUI is modified appropriately & the different functionalities of a software application is verified for a particular locale. It includes verifying all the content translation, date format, number format, currency format, images, online help documents etc for the target audience.
Finalize Scope: Before working on the framework, at first, we need finalize the scope of our localization testing – (It is applicable for any work – not only for localization testing). For ex, languages to be verified, platform to be tested, functionalities to be covered as part of automated testing etc.
Identify the Test cases: Once the testing scope has been finalized, Identify the test cases to be automated. It should cover all the labels, images, number & date formats, currency formats, UI element’s field level validation, error messages, documents, help contents. The application should be able to handle all the special/accented/non-English characters properly.
Language Translation: Once the test cases have been identified, prepare a spreadsheet/property files which contains all the translation for each content of the application for the different languages, the application will support. (In my case, I get a spreadsheet from the BA in below format which I can directly include in my project).
The above key-value mapping is for the below page in our application.
Keyword Driven Framework: It is also called table-driven framework – in which the test script for an application is created using a set of keywords in a table format (usually using spreadsheet). This framework does not depend either on the automation tool or the actual application under test itself.
Even though Keyword driven frameworks might take more time to create, there are many advantages in the framework.
- Automation tool independent
- Application independent
- Programming language independent
- Easy to read test scripts
- Easy to add new test scripts & increases user productivity.
- Very easy to maintain
- No scripting knowledge is required to create test script
- Test script can be created even when the application is not ready for test
Sample Keyword driven localization test script:
Step | Step description for reporting purpose |
Object Name | Either object property of an element / Variable name containing the properties to find the element. |
Action | Action to be done on the element. like Click on a button, Enter some value in thetextbox etc.
|
Param | Parameters to be passed to the action.
|
Identify the Web Elements: In automated testing identifying a right test element is very important. We need some properties like id, name, xpath etc to uniquely identify an element. As I was a HP’s QTP (now it is called UFT) user before, I like its Object Repository concept to keep the properties to identify an element away from the test script. So, I create separate properties file for each page of the application – I still use Page Object Model. But properties are not hard-coded in the class file itself & instead it is read from the properties file – so that I do not need to build the class files in case of property change.
Sample Object Repository file for the above page:
How It Works:
- First all the key value pairs for the language are read & stored in a HaspMap/Dictionary object.
- All the steps from the spreadsheet for the given test case are read.
- The application is launched for the particular language (In my case, I can adjust the language by adding locale code as parameter in the URL)
- TestScriptExecution engine gets all the TestSteps & execute them one by one using KeywordLibrary
KeywordLibrary should handle all the possible actions. For example – ‘VerifyText’ – the below piece of code gets executed everytime.
High Level Framework Design:
- User is responsible for creating the test scripts in the keyword driven format in a spreadsheet as shown above.
- Object repository file is updated once the application is ready.
- Keyword driven tests refer to both Object repository file & translation files to execute a step.
- BaseTest.java is a TestNG base class which has all the common methods. for ex to read the test script from the spreadsheet.
- Locale is passed to the BaseTest via TestNG suite from Jenkins as given below.
Summary:
Thus a keyword driven framework for localization framework is implemented – all the test scripts are executed for the given test Environment, for the given Browser & for the given Language by the user using Jenkins.
Happy Testing 🙂