Eduardo Fabricio Eduardo Fabricio - 1 year ago 80
jQuery Question

Element after and WebDriverException: unknown error: cannot focus element

My javascript line:


My webdriver code line:

wait.until(ExpectedConditions.visibilityOfElementLocated("name"))).sendKeys("Some Name");

When I run the test it throws the following exception:

WebDriverException: unknown error: cannot focus element

So, I have been searching for a solution. There are some issues reported in chromium google code site. There are a lot of suggestions about using
. But it doesn't seem a better solution for me, because it could make a browser dependent code.

Answer Source

After some hours I finally found a solution by using Actions without JavascriptExecuter:

Actions actions = new Actions(driver);
actions.sendKeys("Some Name");;

Well, it worked for me. However, is this way the better solution ?