Sitemap

How selenium handles internalization

2 min readFeb 7, 2018

--

How selenium handles internalization

Let us assume there exist some anchor text associated with a hyperlink. This element can be handled using locators like link text and partial link text. However, this wen application supports multiple languages, what problems can rise? and how selenium handles them? This and much beyond is discussed in this example write up.

Selenium is used to test web applications and since many web applications support multiple languages, we actually use internalization web pages in our example while teaching element locators concepts to our selenium training in Chennai students so that they will not face any problem while working in real time concepts.

So what is the problem?
Let us assume we want to click a link that actually takes you to Bio section
<a href=”http://www.metaexample.com/acc/bio.html">View Bio</a>

As explained earlier, we can test using following

Get Metaforum Tech’s stories in your inbox

Join Medium for free to get updates from this writer.

driver.findElement(By.linkText(“View Bio”)).click()

and this will work perfectly.No problem if it is on a page only with the English language. When we change the language to Japanese, our link will look like following

<a href=”http://www.metaexample.com/acc/bio.html">Profilea jkfas </a>

driver.findElement(By.linkText(“View Bio”)).click()
will fail because there is no link on page with that vie bio text.

One solution to the problem is instead of going for link text or partial link text go for href value because it is not going to change.

So the solution is using href value which is not going to change. you can write a java program to get all href values compare with the attribute we want and then proceed to test the element, which is best and easy web driver way to handle this kind of element. Know any better, feel free to comment here.

--

--