Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drvier.executeScript() doesn't properly cast script result when script args are omitted. #102

Open
BorisOsipov opened this issue Nov 11, 2024 · 0 comments · May be fixed by #107
Open

drvier.executeScript() doesn't properly cast script result when script args are omitted. #102

BorisOsipov opened this issue Nov 11, 2024 · 0 comments · May be fixed by #107
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@BorisOsipov
Copy link

    @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

WebElement element = executeJavaScript("return document.activeElement", "foobar"); works fine.
At least doesn't throw cast error.

@asolntsev asolntsev added bug Something isn't working help wanted Extra attention is needed labels Nov 11, 2024
BorisOsipov added a commit to BorisOsipov/playwrightium that referenced this issue Nov 12, 2024
@BorisOsipov BorisOsipov linked a pull request Nov 12, 2024 that will close this issue
BorisOsipov added a commit to BorisOsipov/playwrightium that referenced this issue Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants