loc07

Selenium WebDriver – Creating a Keyword Driven Framework for Localization Testing

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

loc01

The above key-value mapping is for the below page in our application.

For US English users  :  loc1b

For Spanish users     :   loc1a

 

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:

loc04

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.

  • In my Keyword Executor library – VerifyText action compares the innertext of the element against the vale in the ‘Param‘.
Param Parameters to be passed to the action.

  • ${label.new.examinee.firstname} : Contains the key from the translation file. So based on the language passed to the test, it reads the translations from the spreadsheet for the given key.
  • #{VARIABLE} : Any variable.
  • TEXT : If the Param does not have ${..} or #{..}, then the value in the cell is considered as the parameter to the action for the step.

 

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:

loc03

 

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.

key01

 

High Level Framework Design:

loc07

 

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

loc09

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 🙂

Share This:

Categories: Arquillian, Best Practices, Extend WebDriver, Framework, Jenkins, Selenium

10 comments

  • Shakti

    HI, I stumbled on your website and found lots of interesting and very informative content.
    Just had one question , can you please help me in understanding the part of your framework , how you are doing the content or text verification in localized language(in this case ES). What i understood is that you have Spanish resource file with you (as shown in screenshot above) and while running the test you are extracting the content of particular element from website and comparing that particular extracted string to string which is present in Excel sheet with corresponding language.

    Let me know if my understanding is correct, Would be helpful if you demo that particular portion or provide some sample example or code.

    Best regards,
    Shakti

    • vIns

      Hi Shakti,

      Glad that you found this helpful.
      Yes, Your understanding is totally correct. I was unable to show everything in this article.

      I have just added ‘How It Works’ in this article for you.

      Please let me know if you need more info. Thanks.

  • Mitaleek

    Hi ,

    Thanks a lot for sharing step by step procedure for automating localization testing. I will try to inherit most of the part from your framework.
    But major and probably the blocking issue for my automation work is, I do not have key-value file provided by translators. for details, you can check my case described on this Stack Overflow question : http://sqa.stackexchange.com/questions/15504/what-all-use-cases-we-can-automate-in-localization-testing-selenium.

    It would be really helpful if you can suggest some idea, to generate the key-value pair file (*.properties file) in above case.

    Regards,
    Mitalee

  • Paul P

    I just found your blog, and have already read several of your articles. The two about UFT(QTP) with Jenkins especially. Thank you for all of the great content.

    My question relates to Selenium and UFT functionality and differences.

    At my enterprise we are in the process of creating a full build pipeline. We already are using Jenkins, so the next step was adding an auto deploy and of course that required creating some kind of basic functional testing. We chose Selenium to do this since it is a free and open source product. It works well, and we have added auto deploy, automatic functional testing with Selenium to a small number of our projects.

    We later learned, relearned that we have a UFT license. In our QA environment, there are already QA Engineers in house writing UFT scripts for a lot of our applications. So now I’m looking in to the possibility of using UFT instead of Selenium for our development environment functional tests so we are not duplicating effort.

    A couple of factors that may play a part…
    – Jenkins is deployed on Linux, so we would need to add a Windows server slave to run the UFT tests from my understanding
    – Our application developers are primarily Java developers, there are only a small number of QA developers with VB knowledge
    – At some point we’d like the option to add our functional tests to our workstation build process, shifting left and all, Selenium can easily convert to JUnit tests, not sure how this would be done with UFT
    – We have a limited number of UFT licenses at this point. We can probably handle this from the standpoint of creating the scripts, but I’m not sure how it applies to running a bunch of UFT scripts at the same time
    – While today we only have the need to run these functional tests in development, our long term goal is to run them in QA and Production as well

    Have you found useful functionality that UFT has that goes beyond what Selenium can do, or vice versa?

    What other factors that I haven’t mentioned should I be considering?

    Which product seems suited best for us, in your opinion? I know that there is no one right answer.

    • vIns

      I have been using both UFT & Selenium for 2 different projects.

      Advantage of selenium:

      FREE
      OS independent
      Browser indepedent
      You can use any OOP language you are comfortable with.
      Android/iOS devices automation.
      Can be integrated with unit testing frameworks like JUnit/TestNG etc.
      Parallel testing using Grid (multiple browsers can be opened & testcases can be executed in parallel)

      Disadvantage of Selenium:
      Only for Web based applications.
      Strong programming skill is required.

      Advantage of UFT:
      It can almost automate anything (in Windows only)
      Record & playback feature
      Programming skill is not really required.
      We can come up with test scripts quickly

      Disadvantage of UFT:
      Pricey!
      Works only in windows
      Supports only IE (It will also work with FF & Chrome – but not out of the box – you need to wait for HP to release a plugin. Most of the times, UFT will not work immediately in the latest versions of any browser)
      No support of mobile devices (there are some 3rd party plugins – they are not free)
      Only one instance of browser testing in a machine. So no support of parallel testing.

      So, for your question – I would avise you to decide based on the above advantages & disadvantages. If you are a developer, It makes sense to create selenium test scripts which might be easily integrated with your unit testing frameworks like JUnit/TestNG – it can also be executed as part of your build process like ANT/Maven/Gradle.

      For one of our projects, We have test scripts in UFT only. But it has been designed to work in any environment – DEV,QA,UAT,PPE and PROD. Not just QA environment. So, whenever the new code is dpeloyed – a Jenkins job for the smoketest is triggered for the given environment. While QA actually maintains the test script, anyone can execute it to verify the build. But we have not used it to verify the local. (It seems to be doable though – jenkins slave which has UFT installed can still execute the UFT script against your local environment.)

  • sonal

    hi i understood ur blog completely but the problem i am having that what about the string that are rendered by database and not by the label.prop then what can be done they are going to fail for every automation pass but they shouldnt

    • vIns

      ${..} for getting the information from property file, #{..} for any other variable (#{myclass.getMyVariable()}) will give the data if you need to get anything at run time from the java class. simple plain text will be used for any hard coded data.

Leave a Reply

Your email address will not be published. Required fields are marked *