Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
in DevOps and Agile by (19.7k points)

My javascript line:

$('#name').show();

My webdriver code line:

wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("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 for using JavaScriptExecutor. But it doesn't seem a better solution for me, because it could make a browser-dependent code.

1 Answer

0 votes
by (62.9k points)

The solution is to use Actions without JavascriptExecuter:

Actions actions = new Actions(driver);

actions.moveToElement(website);

actions.click();

actions.sendKeys("Name");

actions.build().perform();

I hope it works for you!

Browse Categories

...