1

We have an AUT a web application which is in Japanese. We are trying to follow below approach (not sure if it is correct) to get the Japanese label text into English.

Approach (using Selenium):

  • Open webpage.
  • Get labels as we crawl webpage.

  • Send each label to an API (Japanese dictionary) to get it translated in English.

  • Set back the translated English word to label using java script executor.

I have managed to get translated English word for the same japanese label. however , I am stuck for setting it back on webpage. Below is the piece of code in selenium that tries to achieve the same.

JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("window.onload=function()document.getElementById('expiry').textContent='Expiration Date';}");

Here , there are no error messages in eclipse console but same time I am not able to see the English text.

HTML

<html>
<body>
<table class="imui-form" style="width:1050px;">
<div class="imui-chapter-title" style="width:1050px;">
<h2>取引先情報</h2>
</div>
<tr>
<th style="width:80px;" >
<label id="expiry">有効期限</label>
</th>
<td style="width:220px;">
<input type="text" placeholder="" value="2016/08/09"  name="fromdate" id="fromdate" maxlength="" style="width:100px; height:15px;">
<img src="./imart/images/calendar_btn.png" />

&nbsp;~&nbsp;
<input type="text" placeholder="" value=""  name="todate" id="todate" maxlength="" style="width:100px; height:15px;">
<img src="./imart/images/calendar_btn.png" />
</td>
</table>
</body>
</html>

With this, I have 2 queries:

  1. Can anyone guide me if my approach is worth a try or if there is any better approach.
  2. How should I make above java script work via selenium.

Your Answer

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

Browse other questions tagged or ask your own question.