3

I am facing a problem while doing localization testing using selenium web driver and java, how to find out the languages supported by a web page?

What I want to achieve is following:

  1. Enter the URL for localization testing.
  2. I want to show the languages supported by the website to the User Automatically.
  3. Then depending upon user chosen language L10N/I18N process goes on
  • You may send HTTP requests with different Accept-Language headers, e.g. Accept-Language: en-US and see whether you will get responses in different languages. This will work if applications recognizes this header. It will also show only implemented supported languages, not the ones required by the specification or customer. – dzieciou Dec 1 '15 at 10:37
  • curl -H "Accept-Language: en-US" google.com -D - – dzieciou Dec 1 '15 at 10:42
  • @dzieciou I am using selenium web driver with java , please provide me some example in java only – sameer joshi Dec 1 '15 at 13:02
  • It would be easier if you explain why do you need to know languages supported by a web page. Also, note that solution might be specific to the application you test. – dzieciou Dec 1 '15 at 13:44
  • 6
    Ask your developers how the website/application determines the locale of the user. Ask them how they unit tested that feature. Then ask them the languages supported. – Joe Strazzere Dec 1 '15 at 16:10
1

With websites supporting multiple languages and the language being select-able from the front-end There is always a list element (drop down) field in the web page.

You can find the list element and fetch all the options in it using Selenium with Java with a script that would look somewhat like

Fetch All Options:

    List<WebElement> options = driver.findElements(
          By.xpath("//*[@id="vehicleTypeName"]/option"));

List<String> text = new ArrayList<>();
for(int i=1; i<options.size(); i++) {
    text.add(options.get(i).getText());
}

Select an Option:

Select dropdown = new Select(driver.findElement(By.id("language")));

dropdown.selectByVisibleText("English ");

or

dropdown.selectByIndex(1);

or

dropdown.selectByValue("EN");

Happy Testing :)

TESTacy

|improve this answer|||||
0

Ask your BA,PM,SA, PO or any of the other chickens.

Note: Chickens refers to the people who make decisions about the product.

|improve this answer|||||
  • i need a java code or is there any possiblity to do in Selenium Web driver. – sameer joshi Dec 3 '15 at 10:55
  • The OP may be a Business Analyst, Project Manager, Systems Analyst or Product Owner, trying to find this out. "Ask someone else" is not really an answer imho – Michael Durrant Mar 8 '16 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.