How to handle internationalization through web driver?

by (324 points)
+1 vote

How to handle internationalisation through web driver?

Describe with code.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

by (171 points)
0 votes
Usually most web applications will use the CMS. They implement the language on the front. So all element identification methods should be the same. E.g. Username and password fields will contain the same name as "uname" and "pwd" for all languages, but lables will change. So implementing this will be very simple.
You will be doing language filtering while asserting texts on the front. E.g. Error message, menu items, etc.
Usually when you are implementing internationalization, your URL will change and it will pretty much talk about your front.
eg. You have a different domain for each language
eg. You will have a different directory for each language
In above case only texts you see in front will change, HTML elements will be the same.
To differentiate between languages, you can create enum and keep it static throughout your test execution.
public enum Language{RU,EN,GU,SA,DE};
Now pass the BaseURL (Application to be tested URL) via environment URL, if you are using Ant with JUnit or via TestNG.xml if you are using TestNG.
While asserting the message you can check language using your BaseURL/Application URL and assert proper message.
While implementing the internationalization, try to avoid element identification using partialLinkedText or linkedText. Try to use xPath or CSS Selector instead.
Hope that helps.