简体   繁体   中英

Selenium SessionNotCreatedException with FirefoxDriver

I am working on an application for my job that extracts data from our web application. I am trying to connect to the website with Selenium, but am receiving a SessionNotCreatedException . Here's what is causing the issue in an isolated environment:

public void testDriver() {
    System.setProperty("webdriver.gecko.driver", "C:\\data\\brandonw\\Desktop\\Docs\\geckodriver.exe");
    WebDriver driver = new FirefoxDriver();
    driver.get("http//user:pass@flag.60north.net/");
}

I originally thought this was an issue from the authentication prompt from our webpage upon initial connection. With Jsoup, I would normally just use a basic authentication header, but with Selenium, I found that putting the user and pass in the url in the above format was the solution. Authentication doesn't seem to be the issue.

The next potential cause I found online was that my Firefox, Selenium, or Geckodriver (any combination of the three) were not up to date. Here is what I am currently working with:

Firefox: v58 Selenium: v3.8.1 geckodriver: 0.19.1

From what I read on github, geckodriver 0.19.0 supports Firefox 55.0+ and Selenium 3.5+, so it doesn't seem to be a version issue either. I'm now stumped with what this could be. My stack trace is as follows:

1517250905541   geckodriver INFO    geckodriver 0.19.1
1517250905561   geckodriver INFO    Listening on 127.0.0.1:32904
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'MKT-PC01', ip: '192.168.3.184', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_151'
Driver info: driver.version: FirefoxDriver
remote stacktrace: stack backtrace:
   0:           0x47e934 - <no info>
   1:           0x47f0a3 - <no info>
   2:           0x442511 - <no info>
   3:           0x4436da - <no info>
   4:           0x42a890 - <no info>
   5:           0x406f5e - <no info>
   6:           0x40cfc9 - <no info>
   7:           0x6bef19 - <no info>
   8:           0x420756 - <no info>
   9:           0x6b96e0 - <no info>
  10:         0x773859cd - BaseThreadInitThunk
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$new$0(W3CHandshakeResponse.java:57)
    at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction$2(W3CHandshakeResponse.java:104)
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
    at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
    at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
    at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
    at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
    at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
    at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:98)
    at com.brandon.MagnaScraper.MagnaSurveyPage.extractQ(MagnaSurveyPage.java:112)
    at com.brandon.MagnaScraper.MagnaSurveyPage.getQ(MagnaSurveyPage.java:59)
    at com.brandon.MagnaScraper.App.main(App.java:54)

Thanks in advance for any help you guys might provide!

Edit: Just as an additional thought, I tried both the 32bit and 64bit of geckodriver as well.

With all the binaries Firefox: v58 , Selenium: v3.8.1 and geckodriver: 0.19.1 in proper configuration and looking at the error as :

10:         0x773859cd - BaseThreadInitThunk
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

BaseThreadInitThunk is the initialization function run during initialization/creation of a new thread. This is the function that will call the start address of your thread, which means :

  • BaseThreadInitThunk is used only to execute your thread's function.
  • You will find its address somewhere on the stack of a newly created thread.
  • It is a function to breakpoint if you want to break in newly created threads.

Hence, I suppose you are missing a mandatory import among one of the following and you have to add both of them :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM