2014-10-27 13 views
6
driverInstanceName.manage().ime().getActiveEngine() 
driverInstanceName.manage().ime().activateEngine(engine) 

ottenere eccezioni come di seguito,Cosa fa esattamente ime() nel selenio?

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

capito che è legato ai dati immissione ma non è sicuro di come sia rilevante di selenio, ha cercato di trovare la risposta in molti forum, ma senza alcun risultato.

risposta

1

sono interessato a saperne di più su metodo dopo aver letto questa domanda e pugni le ricerche di Google in tutto questo:

IME - acronimo di Input Method Engine. Attualmente sembra che questo sia supportato solo nella piattaforma Linux e nel browser Firefox.

Quando si lavora con i caratteri cinesi/giapponesi o multi-byte che ha bisogno di ingresso da Selenio in Linux, è necessario utilizzare framework di ingresso come IBus ei motori realizzati su IBus come anthy (giapponese), pinyin (cinese).

Il seguente esempio di codice è tratto da Selenum I18NTest.java, che cerca il motore anthy per immettere caratteri giapponesi su una macchina 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)); 
    } 

Attenzione: La mia risposta può dare una giusta idea circa la , ancora ulteriori approfondimenti può essere migliorata committer selenio, per come la vedo questa funzione non è in uso diffuso e ha anche un supporto limitato (solo in Linux).

+0

In realtà sta per Input Method Engine - consultare https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/WebDriver.ImeHandler.html un'interfaccia generica per la gestione dell'input dell'utente (es. tramite tastiera, mouse o altri input come una tastiera virtuale su touch screen, controller di gioco, ecc.) – fijiaaron

+0

IME è Input Method Editor non Engine .... Dettagli su IME possono essere trovati su https: //www.w3 .org/TR/ime-api/ – Pooja

+0

fijiaaron, pooja - corretta definizione IME nel post. – parishodak