Unable to Cast WebDriver Instance to JavascriptExecutor Unable to Cast WebDriver Instance to JavascriptExecutor selenium selenium

Unable to Cast WebDriver Instance to JavascriptExecutor


OK, I was working on this for some time and found the solution. Since no one answered the question I'll post the answer I came up with.

Basically, all I needed to do was add implements JavascriptExecutor to both WebDriverDecorator and WebDriverAdapter and add unimplemented methods (such as executeScript(String arg0, Object... arg1) ). I would then cast each respective driver to JS executor inside the unimplemented method and now I'm able to call executeScript() directly on driver of WebDriverDecorator or WebDriverAdapter without casting anything.