Skip to content

Screenshots not working with RemoteWebDriver and Shutterbug 1.6 #103

Closed

Description

@therealdjryan

This bug still seems to be present. I am running selenium grid 4.1.2 and shutterbug 1.6

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:918)
	at com.assertthat.selenium_shutterbug.utils.web.Browser.takeFullPageScreenshotChromeCommand(Browser.java:713)
	at com.assertthat.selenium_shutterbug.utils.web.Browser.takeFullPageScreenshot(Browser.java:155)
	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)

Activity

  1. self-assigned this
    on Mar 25, 2022
  2. glibas commented on Mar 25, 2022

    @glibas
    Member

    Hi @therealdjryan cannot reproduce it here. Could you please share example project/code

  3. therealdjryan commented on Mar 25, 2022

    @therealdjryan
    Author
  4. glibas commented on Mar 26, 2022

    @glibas
    Member

    Hi @therealdjryan ,
    It works fine with declaring WebDriver as

    WebDriver driver = new RemoteWebDriver(new URL("http://127.0.0.1:4444/wd/hub"), new ChromeOptions());

    It does not work with declaring through builder as in your example

    WebDriver driver = RemoteWebDriver.builder().address("http://127.0.0.1:4444") .addAlternative(new ChromeOptions()).build();

    The reason for that is that CommandExecutor is instantiated by a lambda result in RemoteWebDriverBuilder

    CommandExecutor executor = (CommandExecutor)result.map((res) -> { return this.createExecutor(handler, res); });
    Will have a look how we can workaround that. In the meantime you can avoid using RemoteWebDriverBuilder which is still marked as Beta.

  5. therealdjryan commented on Mar 28, 2022

    @therealdjryan
    Author

    Hi @glibas, Thanks for chasing down the workaround. Unfortunately in my environment I need to be able to set the readTimeout to handle a couple sluggish pages. I don't think there's a way to do that without using the builder, or rather using ClientConfig which is set in the builder

  6. glibas commented on Mar 31, 2022

    @glibas
    Member

    Hi @therealdjryan ,
    Still looking how to make it work with builder. There are some issues with invoking method using reflection on lambda refs as mentioned above.

    There is a way, however to set your readTimeout without using builder. It's not pretty but works (effectively same what RemoteWebdriver does under the hood but with Custom ClientConfig instead of default one)

    URL remoteAddress = new URL("http://localhost:4444/wd/hub");
    Tracer tracer = OpenTelemetryTracer.getInstance();
    ClientConfig config = ClientConfig.defaultConfig().baseUrl(remoteAddress).readTimeout(Duration.ofSeconds(60));
    CommandExecutor executor = new HttpCommandExecutor(Collections.emptyMap(), config, new TracedHttpClient.Factory(tracer, org.openqa.selenium.remote.http.HttpClient.Factory.createDefault()));
    CommandExecutor executorTraced =  new TracedCommandExecutor(executor, tracer);
    WebDriver webDriver = new RemoteWebDriver(executorTraced, new ChromeOptions());
    
  7. therealdjryan commented on Mar 31, 2022

    @therealdjryan
    Author

    @glibas,
    I am perfectly happy with this solution, it works great. Could you update the readme so future generations know the limitation/solution

    Thanks!
    Dennis

  8. glibas commented on Mar 31, 2022

    @glibas
    Member

    Hi @therealdjryan ,
    Will add this to Readme unless I can marry it up with the builder.
    Thanks for raising!
    Glib

  9. added a commit that references this issue on Aug 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions