Search code examples
javaselenium-webdrivermultilingual

How can I make sure in selenium that language switcher converting content language


Scenario :

  1. Go to website : https://www.virtuality.fashion/it/home_it/
  2. Click on Flag of France from top right
  3. Verify that page language must changed to french language

How can I verify that language has been changed and page content changed to french.

I am trying to automate it so how can I verify above via selenium. Steps are simple so I did not get any issue till click on flag but unable to find any method or option in selenium automation which make sure that page content language has been changed.

I thought to copy all content and paste into google translate and then compare content with English language but this seems quite complex if there will be more pages to verify.


Solution

  • I don't believe Selenium is a good tool for content testing. You'll just waste your time and resources.

    Anyway, if there're no alternatives on how to verify that localization files are correctly applied on lower testing levels, I'd add some smart validation with a bit of randomization.

    After language switching you can pick a random element (defined in you page object) which has a text, and then send it to some language detection service. Assuming you have frequent builds, randomization may help you to detect anomalies in different site areas.

    But it definitely makes no sense to parse the entire content via Selenium and validate it against some hardcoded expected result. Any content change may cause failures and increase support time.

    As an alternative, if you have a static content, you may take a look at some specialized solutions like applitools.