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

Capture.FULL not working with the latest Remote WebDriver #96

Closed
a-tikhomirov opened this issue Jan 15, 2022 · 9 comments
Closed

Capture.FULL not working with the latest Remote WebDriver #96

a-tikhomirov opened this issue Jan 15, 2022 · 9 comments
Assignees

Comments

@a-tikhomirov
Copy link

a-tikhomirov commented Jan 15, 2022

When using Selenide 6.2.0 (with Selenium 4.1.1 and WebDriver 4.1.1) and RemoteWebDriver Chrome 97

Shutterbug.shootPage(WebDriverRunner.getWebDriver(), Capture.FULL)

causes:

java.lang.IllegalArgumentException: object is not an instance of declaring class
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.assertthat.selenium_shutterbug.utils.web.Browser.defineCustomCommand(Browser.java:909)
	at com.assertthat.selenium_shutterbug.utils.web.Browser.takeFullPageScreenshotChromeCommand(Browser.java:715)
	at com.assertthat.selenium_shutterbug.utils.web.Browser.takeFullPageScreenshot(Browser.java:157)
	at com.assertthat.selenium_shutterbug.core.Shutterbug.shootPage(Shutterbug.java:154)
	at com.assertthat.selenium_shutterbug.core.Shutterbug.shootPage(Shutterbug.java:83)
	at com.assertthat.selenium_shutterbug.core.Shutterbug.shootPage(Shutterbug.java:69)
@a-tikhomirov a-tikhomirov changed the title Capture.FULL not working with latest Remote WebDriver Capture.FULL not working with the latest Remote WebDriver Jan 15, 2022
@glibas glibas self-assigned this Feb 2, 2022
@anna-shchurok
Copy link
Collaborator

Checked on Selenoid 1.10.7 for Chrome 97.0 and Chrome 98.0
using command Shutterbug.shootPage(driver, Capture.FULL).save();
didn't not manage to reproduce.

@a-tikhomirov is 97.0 version where the issue started to reproduce? on 96.0 it is all ok?

Also java.lang.IllegalArgumentException: object is not an instance of declaring class usually means the type of driver is incompatible. What type of driver is actually passed? is it RemoteWebDriver?

@therealdjryan
Copy link

therealdjryan commented Feb 19, 2022

I get the error with Chrome 97 using RemoteWebDriver. I'm using Selenium Grid 4.1.2

@gregdymek
Copy link

same here
java.lang.IllegalArgumentException: object is not an instance of declaring class at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at com.assertthat.selenium_shutterbug.utils.web.Browser.defineCustomCommand(Browser.java:909) at com.assertthat.selenium_shutterbug.utils.web.Browser.takeFullPageScreenshotChromeCommand(Browser.java:715) at com.assertthat.selenium_shutterbug.utils.web.Browser.takeFullPageElementScreenshot(Browser.java:181) at com.assertthat.selenium_shutterbug.utils.web.Browser.takeFullElementScreenshotScroll(Browser.java:410) at com.assertthat.selenium_shutterbug.core.Shutterbug.shootElement(Shutterbug.java:292) at com.assertthat.selenium_shutterbug.core.Shutterbug.shootElement(Shutterbug.java:214)

@gregdymek
Copy link

Screenshot 2022-02-20 at 12 39 28

when I called in for a delegate, there was no error (it just returned null), I'm using remote driver + selenium grid

@gregdymek
Copy link

gregdymek commented Feb 20, 2022

Here is the fix:

private void defineCustomCommand(String name, CommandInfo info) {
        try {
            Method defineCommand = HttpCommandExecutor.class.getDeclaredMethod("defineCommand", String.class, CommandInfo.class);
            defineCommand.setAccessible(true);
            CommandExecutor commandExecutor = ((RemoteWebDriver) this.driver).getCommandExecutor();
            if (commandExecutor instanceof TracedCommandExecutor) {
                Field delegateField = TracedCommandExecutor.class.getDeclaredField("delegate");
                delegateField.setAccessible(true);
                commandExecutor = (CommandExecutor) delegateField.get(commandExecutor);
            }
            defineCommand.invoke(commandExecutor, name, info);
        } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException | NoSuchFieldException e) {
            throw new RuntimeException(e);
        }
    }

@arazantsau
Copy link

Also facing this issue (Selenium 4 + Selenoid)

@erichimm
Copy link

I'm facing the same issue (selenium-java 4.1.2 + chrome 98)

@glibas glibas closed this as completed in 9f60d06 Mar 22, 2022
@glibas
Copy link
Member

glibas commented Mar 22, 2022

@gregdymek thank you for suggesting the fix. The fix will be deployed with v1.6

@therealdjryan
Copy link

@gregdymek, @glib-briia,
The timing of your response if crazy. I just put in a PR with @gregdymek's fix
https://github.com/assertthat/selenium-shutterbug/pull/102/files?diff=unified&w=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants