Search code examples
windows-phone-8sendkeysremotewebdriver

Why the method "SendKeys" doesn't work with Windows Phone WebDriver?


I use Windows Phone and a RemoteWebDriver but when I try to use a "SendKeys" method, I got this error :

Unexpected error. Call could not be fullfield. JavaScript injection failed.

Example :

driver.FindElement(By.Id("ID")).SendKeys("string");

Best regards,

Xialuna


Solution

  • So, I found a solution.

    I create a new function like this :

    public void javascriptSendKeys(String id, String value)
    {
        String script = "document.getElementById(\"" + id + "\").value=\"" + value + "\" ";
        ((IJavaScriptExecutor)driver).ExecuteScript(script);
    }
    

    And I use it when I need to use a SendKeys method.

    It's work fine for me.

    Have a nice day !

    Xialuna