了濃厚的興趣閱讀了這個問題後,詳細瞭解方法和衝壓解決這個谷歌搜索:
IME - 代表輸入法引擎。目前看來這只是在Linux平臺和Firefox瀏覽器中才支持的。
當與在Linux中硒需要輸入中國/日本或者多字節字符的工作,你必須使用像IBus輸入框架和像anthy(日本)對下iBus實施的引擎,pinyin(中國)。
下面的代碼示例來自Selenium的I18NTest.java,它尋找anthy
引擎以在Linux機器上輸入日文字符。
@NeedsFreshDriver
@Ignore(value = {IE, CHROME, FIREFOX},
reason = "Not implemented on anything other than Firefox/Linux at the moment.")
@NotYetImplemented(HTMLUNIT)
@Test
public void testShouldBeAbleToActivateIMEEngine() throws InterruptedException {
assumeTrue("IME is supported on Linux only.",
TestUtilities.getEffectivePlatform().is(Platform.LINUX));
driver.get(pages.formPage);
WebElement input = driver.findElement(By.id("working"));
// Activate IME. By default, this keycode activates IBus input for Japanese.
WebDriver.ImeHandler ime = driver.manage().ime();
List<String> engines = ime.getAvailableEngines();
String desiredEngine = "anthy";
if (!engines.contains(desiredEngine)) {
System.out.println("Desired engine " + desiredEngine + " not available, skipping test.");
return;
}
ime.activateEngine(desiredEngine);
int totalWaits = 0;
while (!ime.isActivated() && (totalWaits < 10)) {
Thread.sleep(500);
totalWaits++;
}
assertTrue("IME Engine should be activated.", ime.isActivated());
assertEquals(desiredEngine, ime.getActiveEngine());
// Send the Romaji for "Tokyo". The space at the end instructs the IME to convert the word.
input.sendKeys("toukyou ");
input.sendKeys(Keys.ENTER);
String elementValue = input.getAttribute("value");
ime.deactivate();
assertFalse("IME engine should be off.", ime.isActivated());
// IME is not present. Don't fail because of that. But it should have the Romaji value
// instead.
assertTrue("The elemnt's value should either remain in Romaji or be converted properly."
+ " It was:" + elementValue, elementValue.equals(tokyo));
}
注意:我的回答可以提供關於一個公平的想法,還是更多的見解,可以通過硒提交者改善,因爲我看到這個功能沒有被廣泛使用,並且還具有有限的支持(只在Linux中)。
它實際上代表的輸入法引擎 - 看到https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/WebDriver.ImeHandler.html一個通用的接口,用於處理用戶輸入(例如通過鍵盤,鼠標或其他輸入如觸摸屏上的軟鍵盤,遊戲控制器等) – fijiaaron 2016-02-16 22:41:55
IME是輸入法編輯器而不是引擎....有關IME的詳細信息可以在https://www.w3 .org/TR/ime-api/ – Pooja 2016-05-24 03:32:45
fijiaaron,pooja - 修正後的IME定義。 – parishodak 2016-06-03 17:45:34