Open BorisOsipov opened 1 week ago
@Test public void jsExecuteCanCastToWebElement() { WebElement element = executeJavaScript("return document.activeElement"); } static <T> T executeJavaScript(String jsCode, Object... arguments) { return (T) jsExecutor(driver).executeScript(jsCode, arguments); }
It fails with java.lang.ClassCastException: class java.lang.String cannot be cast to class org.openqa.selenium.WebElement
java.lang.ClassCastException: class java.lang.String cannot be cast to class org.openqa.selenium.WebElement
WebElement element = executeJavaScript("return document.activeElement", "foobar"); works fine. At least doesn't throw cast error.
WebElement element = executeJavaScript("return document.activeElement", "foobar");
It fails with
java.lang.ClassCastException: class java.lang.String cannot be cast to class org.openqa.selenium.WebElement
WebElement element = executeJavaScript("return document.activeElement", "foobar");
works fine. At least doesn't throw cast error.