0

I'm new to Selenium Automation Testing. While exploring Amazon Website, there's change language preferences. How to manage these Language setting preferences in amazon website for automated testing in Project Setup using Selenium with TestNG Framework?

https://www.amazon.in/gp/customer-preferences/select-language/ref=topnav_lang?preferencesReturnUrl=%2F%3Fext_vrnc%3Dhi%26tag%3Dgooghydrabk-21%26ascsubtag%3D_k_CjwKCAiA7939BRBMEiwA-hX5J1Cmk4hhtMQZqerf2Odf2mIe6KDGzXezpZqlsx8iDeNm3sTFOACpfBoC7IQQAvD_BwE_k_%26ext_vrnc%3Dhi%26gclid%3DCjwKCAiA7939BRBMEiwA-hX5J1Cmk4hhtMQZqerf2Odf2mIe6KDGzXezpZqlsx8iDeNm3sTFOACpfBoC7IQQAvD_BwE%26network%3Dg

New contributor
Praneetha Kethireddy is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    What have you tried? It's better to post a specific problem you want to solve. – pavelsaman Nov 20 at 22:42
-1

This works as same as English :

    driver.get(
            "https://www.amazon.in/gp/customer-preferences/select-language/ref=topnav_lang?preferencesReturnUrl=%2F%3Fext_vrnc%3Dhi%26tag%3Dgooghydrabk-21%26ascsubtag%3D_k_CjwKCAiA7939BRBMEiwA-hX5J1Cmk4hhtMQZqerf2Odf2mIe6KDGzXezpZqlsx8iDeNm3sTFOACpfBoC7IQQAvD_BwE_k_%26ext_vrnc%3Dhi%26gclid%3DCjwKCAiA7939BRBMEiwA-hX5J1Cmk4hhtMQZqerf2Odf2mIe6KDGzXezpZqlsx8iDeNm3sTFOACpfBoC7IQQAvD_BwE%26network%3Dg");
    driver.findElement(By.xpath("//input[@value=\"kn_IN\"]/../..")).click();

    String value = driver.findElement(By.xpath("//*[text()='ಅನುವಾದ']")).getText();
    Assert.assertEquals(value,"ಅನುವಾದ");

Hi you could try converting the local text to Unicode values first, use the below website to do that:

https://www.branah.com/unicode-converter

So the unicode character for :

ಅನುವಾದ is

\u0c85\u0ca8\u0cc1\u0cb5\u0cbe\u0ca6

Now use that value in your xpath:

String a=driver.findElement(By.xpath("//*[text()='\u0c85\u0ca8\u0cc1\u0cb5\u0cbe\u0ca6']")).getText();
| improve this answer | |
  • Searching by text on the full page is incredably unreliable, since unrelated changes will affect your code. – João Farias Nov 21 at 20:10
  • How will it affect the code if text never changes ? The intension of answer was the approach for test validation is same like you do normally – PDHide Nov 21 at 20:37
  • If ಅನುವಾದ happens anywhere on the DOM tree search before the radio buttons, you would be fetching the wrong sub-tree. – João Farias Nov 21 at 20:39
  • Ya that was an example stating you can use locale text for assertions and for xpath – PDHide Nov 21 at 21:21

Your Answer

Praneetha Kethireddy is a new contributor. Be nice, and check out our Code of Conduct.

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.