English 中文(简体)
• 如何在使用硫化物的电离层中核实当地语言
原标题:How to verify Local language in UI using Selenium

我是新来测试的,并有一个问题,即我们如何用塞伦乌语核实当地语言。 假设我有某种联系,让我选择语言,这样,我就能够选择一种语言来核实这一点?

最佳回答

页: 1 让我们坐在一页上,要么只用一个部分。

<div>
    It s time to kick ass and chew bubble gum!
</div>

<div>
    Il est temps de botter le cul et mâcher de la gomme à bulles!
</div>

接着,在塞伦堡,你可以拿到这个要素,获得内部文本并核实! Java例:

// assuming driver is a good WebDriver instance
WebElement elem = driver.findElement(By.xpath("//div"));
if (elem.getText().contains("kick ass")) {
    System.out.println("It s English!");
} else if (elem.getText().contains("botter le cul")) {
    System.out.println("It s French!");
}

至 Java7时,你甚至可以使用“缝.”的交换机,这样你就可以对许多语言进行消化测试。

问题回答

祝福

  • search for flag of that language on the page
  • check number formatting, or time formatting (does change in some locales)
  • Verify some well known text (like greeting) is changed. Say, from Good evening to Dobrý večer (that was in Czech ;) )

We use dictionary files for l10n. Dictionary is an xml file with strings stored like <string key="Cancel">Cancel</string>. So for testing purposes we replace all </string> with something like @@@</string> and replace all spaces between <string key="..."> and </string> with _ (can be done in notepad++ with ctrl+h, spaces can be replaced with the help of this answer for example). Then we select language that corresponds to modified dictionary at our website. Next step is done by Selenium IDE script: browsing through the whole web site and storing pages text with the use of Selenium IDE command storeBodyText | text. Then parsing and echo all words that is not ended with @@@ and analyze if it ok or the word that should be translated is hard-coded.

Not pure automation but better than nothing :) I think this approach can be applied not only for xml-dictionary files but for any storage you use for your strings.

PS。 如果你不想进行本地化测试,但只是想确定,通过点击某些语言的使用(恐怕是你所期望的),在你点击之后,你可以从任何内容中获取案文,并与预期案文进行比较(storeText(定位器,可变Name)

<!-- Using Selenium IDE -->
<tr>
<td>storeAttribute</td>
    <td>//html@lang</td>
    <td>language</td>
</tr>
<tr>
    <td>echo</td>
    <td>The label is ${language}</td>
    <td></td>
</tr>




相关问题
Deploying WCF application

I have IIS-Hosted WCF application and services. I want to automate the process to deploy this application into test/Acceptance test/production environments What is the best way to automate the process ...

CGWindowID from AXUIElement

I m trying to automate a foreign OSX application using the accessibility API. Some of the state of the application isn t available through the API, so I acquire it through screen scraping. To do this, ...

Snapping pictures from Windows C# Canon SDK vs PTP or MTP

I am hoping to receive some general guidance on accomplishing a seemingly simple goal. I have a DSLR camera (Canon EOS 50D) and need to write an application that will tell the camera to take a ...

热门标签