1
votes

not able to run the basic selenium code Using:

  • FireFox 52 esr
  • Selenium jar 3.141.59
  • geckodriver-v0.23.0-win64

Code trials (test.java):

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class test {

    public static void main(String args[])
    {
        System.out.println("Hello");
        System.setProperty("webdriver.gecko.driver","C://Users//anila//Downloads//geckodriver-v0.23.0-win64//geckodriver.exe");
        WebDriver driver=new FirefoxDriver();
        driver.get("www.google.com");
    }

}

"C:\Program Files\Java\jdk-11.0.1\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.3.2\lib\idea_rt.jar=59660:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.3.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\anila\out\production\anila;C:\Users\anila\Desktop\Selenium Jar\client-combined-3.141.59.jar;C:\Users\anila\Desktop\Selenium Jar\libs\okio-1.14.0.jar;C:\Users\anila\Desktop\Selenium Jar\libs\okhttp-3.11.0.jar;C:\Users\anila\Desktop\Selenium Jar\libs\guava-25.0-jre.jar;C:\Users\anila\Desktop\Selenium Jar\libs\commons-exec-1.3.jar;C:\Users\anila\Desktop\Selenium Jar\libs\byte-buddy-1.8.15.jar;C:\Users\anila\lib\com.springsource.org.testng-6.5.2.jar" test Hello 1547227022145 mozrunner::runner INFO Running command: "C:\Program Files\Mozilla Firefox\firefox.exe" "-marionette" "-foreground" "-no-remote" "-profile" "C:\Users\anila\AppData\Local\Temp\rust_mozprofile.NnD9S4e3gbOY" [GFX1]: Potential driver version mismatch ignored due to missing DLLs 0.0.0.0 and 0.0.0.0 1547227023423 Marionette INFO Listening on port 2828 [GFX1]: Potential driver version mismatch ignored due to missing DLLs 0.0.0.0 and 0.0.0.0 [Child 5320] ###!!! ABORT: Aborting on channel error.: file c:/builds/moz2_slave/m-esr52-w64-000000000000000000/build/src/ipc/glue/MessageChannel.cpp, line 2143 Exception in thread "main" org.openqa.selenium.WebDriverException: connection refused Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48' System info: host: 'LAPTOP-1QFLADIK', ip: '192.168.2.29', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.1' Driver info: driver.version: FirefoxDriver remote stacktrace: at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62) at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30) at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958) at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127) at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:147) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:125) at test.main(test.java:11)

2

2 Answers

0
votes

As per your question and the error trace logs:

  • You are using java.version: '11.0.1'

As per Can't compile Java9 module with selenium-java as dependency it seems the Selenium packages can't be compiled with Java 9 due to split packages and till May 15, 2018 Selenium wasn't fully compatible with Java 9.

But as per this comment @Jarob22 mentioned, Selenium works just fine using Java 10. Java 9 is already eol and there's not much point adding extra stuff to try and support just it if 10 works.

But with the landing of e57914a Simon introduced us with basic JPMS support. With this availability (mhomnag/selenium-java10-reproducer@bc63889) now actually builds but you may have to Remove the WebDriverWaiter and just use a sleep for now.

Java 11

selenium-server-standalone-3.141.59.jar is still not compatible with Java 11. But once Java 11 ships and Buck supports it the toolchain witll be rejiged to support Java 11.

0
votes

The reason your code doesn't work may be that geckodriver 0.23 supports Firefox since 57 version. Check supported platforms page for more info. Updating Firefox seems to be the best solution. (if you can do it)