Skip to content

[BUG] Failed to create driver when using in sbt plugin #1447

@gmkumar2005

Description

@gmkumar2005

System info

  • Playwright Version: [1.40.0]
  • Operating System: [macOS] (Not tested on other os. It is fair to assume this issue exists on all OS)
  • Browser: [All]
  • Other info:

Expected
The playwright drivers should be loaded and open the browser when running in an sbt plugin.

I am using playwright in an sbt plugin. It fails to load the driver with following error
Caused by: java.lang.NullPointerException: Cannot invoke "java.net.URL.toURI()" because the return value of "java.lang.ClassLoader.getResource(String)" is null

Actual

I am using playwright in an sbt plugin. It fails to load the driver with following error
Caused by: java.lang.NullPointerException: Cannot invoke "java.net.URL.toURI()" because the return value of "java.lang.ClassLoader.getResource(String)" is null

The root cause seems to be due to the way class loader is used in the DriverJar.Java
The function getDriverResourceURI() is using a classloader from current Thread
ClassLoader classloader = Thread.currentThread().getContextClassLoader();

sbt is not able to provide all the libraries inthis class loader. It works with DriverJar.class.getClassLoader()

Can this function getDriverResourceURI() be updated to use the class loader as in DriverJar.class.getClassLoader()

public static URI getDriverResourceURI() throws URISyntaxException {

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions