+1 vote
1 view
in DevOps and Agile by (19.8k 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 (63.4k 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!

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...