What exactly does ime () do in selenium?

driverInstanceName.manage().ime().getActiveEngine() driverInstanceName.manage().ime().activateEngine(engine) 

getting exceptions as shown below

 org.openqa.selenium.WebDriverException: unimplemented command: session/3f83e50445b7c179249aada785c8e910/ime/activate Command duration or timeout: 2 milliseconds 

I realized that he was involved in data entry, but not sure how appropriate he was in selenium, tried to find the answer in many forums, but to no avail.

+6
source share
1 answer

I am interested in learning more about the ime() method after reading this question and punching Google search queries around this:

IME - indicates an input / output mechanism. Currently, it seems that this is only supported on the Linux platform and the Firefox browser.

When working with Chinese / Japanese or multibyte characters that should be entered by Selenium in linux, you need to use an input structure, for example, IBus and engines implemented on IBus, such as anthy (Japanese), pinyin (Chinese).

The following code sample is taken from Selenium I18NTest.java , which is looking for an anthy mechanism for entering Japanese characters on a Linux machine.

  @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 value should either remain in Romaji or be converted properly." + " It was:" + elementValue, elementValue.equals(tokyo)); } 

Caution:. My answer can give a fair idea about ime() , but even more considerations can be improved with selenium committers, as I see that this function is not widely used, and also has limited support (only on Linux).

+1
source

Source: https://habr.com/ru/post/977276/


All Articles