MachinePublishers / jBrowserDriver

A programmable, embeddable web browser driver compatible with the Selenium WebDriver spec -- headless, WebKit-based, pure Java
Other
809 stars 143 forks source link

Support Java 11 #341

Open boyarsky opened 5 years ago

boyarsky commented 5 years ago

This is related to #285 . Java 11 is a long term support release so more people will be switching to it than Java 9. Also the problem got worse with Java 11. The version of Java FX for Java 11 (open jfx) - https://mvnrepository.com/artifact/org.openjfx gets past the Cookie Manager class not found.

However, Java 11 moves the Robot class from com.sun.glass.ui to javafx.scene.robot. This means that you can’t just use OpenJFX’s version of JavaFX with JDK 11. And since Java FX is tied to the version of Java, you can't use the old Java 8 JavaFX jar.

This means JBrowser Driver is stuck on Java 8 until you explicitly add support for Java 11. I hope this is on the radar. This project is the only headless driver I've found for Java that doesn't require installing anything on the server. Over time, having to stay on Java 8 will become an even bigger problem.

ArloL commented 5 years ago

I have tried getting it to work: https://github.com/ArloL/jBrowserDriver/tree/jdk11

I am stuck that CookieManager.setDefault throws an Exception when starting the server. Eclipse also says that method is not accesible. Anyone got an idea?

BrendM commented 5 years ago

Any change on this? I am interested in trying this out but have to use jdk11.

zli-ray commented 5 years ago

@ArloL Maybe like this: https://stackoverflow.com/questions/47262810/eclipse-java9-how-to-access-internal-javafx-packages/47265176#47265176

boyarsky commented 5 years ago

That’s not the problem. You can run non module code in Java 11. The problem is a Java 8 specific JavaFX API.

On Sat, Jan 12, 2019 at 11:37 AM zli-ray notifications@github.com wrote:

@ArloL https://github.com/ArloL Maybe should put a module-info.java into jBrowserDriver to make it a modular.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/MachinePublishers/jBrowserDriver/issues/341#issuecomment-453761539, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZcnrKhcs7SaqKtfBV7fHxwOgsRYFw3ks5vCg9RgaJpZM4YxeV0 .

zli-ray commented 5 years ago

@ArloL @boyarsky I cloned ArloL's branch : ArloL/jBrowserDriver/tree/jdk11, and tested it in my eclipse. It seems that it works good. (I changed nothing.)

Below are my pom.xml, test code and screenshot.

pom and test code.zip

screenshot

tatklim commented 5 years ago

@ArloL @boyarsky I cloned ArloL's branch : ArloL/jBrowserDriver/tree/jdk11, and tested it in my eclipse. It seems that it works good. (I changed nothing.)

Below are my pom.xml, test code and screenshot.

pom and test code.zip

screenshot

@ArloL Excellent! Based on the success of @zli-ray , I have also cloned your new branch ArloL/jBrowserDriver/tree/jdk11 and then deployed a new JAR file "jbrowserdriver-1.0.2-SNAPSHOT.jar" utilizing your new XML file "pom.xml". With the new JAR, I can concur with @zli-ray that it is working for JDK 11+ based on the following 2 dependencies:

  1. [JDK 11] http://oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html
  2. [JavaFX 11] http://gluonhq.com/products/javafx

@ArloL Would you please promote the new version "1.0.2-SNAPSHOT" to production? Thank you very much!

Please note that I need to use the flag "--jbd.javaoptions" for the following 11 Java options (which must be separated by tab) for JDK 11+: --add-exports javafx.graphics/com.sun.glass.ui=ALL-UNNAMED --add-exports javafx.web/com.sun.javafx.webkit=ALL-UNNAMED --add-exports javafx.web/com.sun.webkit=ALL-UNNAMED --add-exports javafx.web/com.sun.webkit.network=ALL-UNNAMED --add-modules=ALL-MODULE-PATH --module-path [the local path to JavaFX 11, for example, /usr/local/javafx-sdk-11.0.2/lib]

tatklim commented 5 years ago

@ArloL As an added bonus, I have successfully tested your new branch ArloL/jBrowserDriver/tree/jdk11 in headless mode using Monocle and can confirm it is working for JDK 11+ based on the following 3 dependencies:

  1. [JDK 11] http://oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html
  2. [JavaFX 11] http://gluonhq.com/products/javafx
  3. [OpenJFX Monocle jdk-11+26] http://central.maven.org/maven2/org/testfx/openjfx-monocle/jdk-11+26/openjfx-monocle-jdk-11+26.jar

@ArloL Would you please promote the new version "1.0.2-SNAPSHOT" to production? Thank you very much!

In headless mode, I need to use the flag "--jbd.javaoptions" for the following 13 Java options (which must be separated by tab) for JDK 11+: -Dglass.platform=Monocle -Dmonocle.platform=Headless --add-exports javafx.graphics/com.sun.glass.ui=ALL-UNNAMED --add-exports javafx.web/com.sun.javafx.webkit=ALL-UNNAMED --add-exports javafx.web/com.sun.webkit=ALL-UNNAMED --add-exports javafx.web/com.sun.webkit.network=ALL-UNNAMED --add-modules=ALL-MODULE-PATH --module-path [the local path to JavaFX 11, for example, /usr/local/javafx-sdk-11.0.2/lib]

sorin-costea commented 4 years ago

Any plans to merge this?

balazs-zsoldos commented 3 years ago

Hi,

I updated the code to use openjfx 16 (that is compatible with JDK 11). I created a fork and released it to maven central with a different groupId. Feel free to merge back the changes to this repo.

It is available at https://github.com/everit-org/jBrowserDriver

elect86 commented 1 year ago

@balazs-zsoldos could you share the gav coordinates?

Gotcha implementation("org.everit.forks:org.everit.forks.com.machinepublishers.jbrowserdriver:1.1.1-jdk11.1") but still fails with jdk11 unfortunately..

balazs-zsoldos commented 1 year ago

@elect86 Works for us. However, we decided to leave jbrowserdriver behind as nobody maintains it and it does not work on Java 17. We use simple selenium webdriver instead (e.g.: chrome webdriver)