SyntaxFix
Write A Post
Hire A Developer
Questions
The focus only works if the window is focused.
Use ((JavascriptExecutor)webDriver).executeScript("window.focus();"); to be sure.
((JavascriptExecutor)webDriver).executeScript("window.focus();");