operasoftware / operachromiumdriver

OperaDriver for Chromium-based Opera releases

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"session not created exception" with selenium standalone

joeyparrish opened this issue · comments

I get this error trying to start Opera on Mac using selenium:

Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: '...', ip: '...', os.name: 'Mac OS X',
    os.arch: 'x86_64', os.version: '10.10.5', java.version: '1.8.0_71'
Driver info: org.openqa.selenium.opera.OperaDriver
Capabilities [{message=session not created exception
from unknown error: Runtime.executionContextCreated has invalid 'context': {
      "auxData":{"frameId":"1258.1","isDefault":true},"id":1,"name":"","origin":"://"}
  (Session info: Opera with embedded Chromium 54.0.2840.59)
  (Driver info: OperaDriver=0.2.0 (ba47709ed9e35ce26dbd960fb5d75be104290d96),
                platform=Mac OS X 10.10.5 x86_64), platform=ANY}]
Session ID: 8ee703fc6af7bf1e4db41efe8c1a0fb2

Opera starts, then closes immediately.

I'm using v0.2.2 of operachromium driver, but due to #10, the above output shows v0.2.0.

Other browsers run fine. My selenium node config is this:

{
  "capabilities": [
    {
      "browserName": "firefox",
      "maxInstances": 1,
      "seleniumProtocol": "WebDriver"
    },
    {
      "browserName": "operablink",
      "maxInstances": 1,
      "seleniumProtocol": "WebDriver",
    },
    {
      "browserName": "safari",
      "maxInstances": 5,
      "seleniumProtocol": "WebDriver"
    }
  ],

  "maxSession": 4,
  "port": 5555,
  "host": "localhost",
  "register": true,
  "registerCycle": 5000,
  "hubPort": 4444,
  "hubHost": "localhost"
}
commented

I could never get operadriver v0.2.2 to work with Opera browsers versions later than Opera 32. Chromium releases new chromedrivers that match with the proper Chrome browser version. You can see the Opera -> Chromium version here I was able to get later chromedrivers to work with newer Opera browsers and just rename the binary accordingly. Of course, I'm not using it in a hub with node configuration so not exactly sure how to tell you to configure your capabilities. I am launching the chromedriver and then connecting to it while specifying the Opera browser binary path. Maybe this helps, maybe not.

Doing that would prevent me from having both Opera and Chrome running in the same selenium node, and it feels like a huge hack. I'd prefer Opera to fix their driver, or at least release the source so someone else can.

commented

I don't see how it would prevent you from having both Opera and Chrome on the same node ... I was suggesting that you use the proper chromedriver binary in place of the operadriver binary which may alleviate this problem on getting a session with Opera - you can even rename it if it makes you feel better... Yes, you have to use ChromeOptions. It is a hack, but about the only option that works since technically Opera is Chromium. operadriver v0.2.2 will not launch later versions of Opera. We haven't seen anything from Opera on this in about a couple of years, so I wouldn't expect to - hopefully I'm wrong. Good luck!

Maybe I misunderstood. I'll give it a try.

So, did it work?

Luke, thank you for getting back. I tried as you pointed out above and in #28, however Opera immediately quits after being launched in my case (Mac, current Opera, Selenium 2.53.1). That's why I wanted to make sure, that this "hack" still works.

I'll investigate this further as soon as I have some more spare time. Probably it was just a mistake on my side. Good to know that it should still work as you described!

commented

I just verified on Mac 10.12, Opera 41. Here's the logic and setup:

  • Opera History shows that Opera 41 is based off of Chromium 54
  • ChromeDriver Notes shows that ChromeDriver 2.24 supports Chromium 54 (or 2.25 but I tested with 2.24 since already had that downloaded

I launch the ChromeDriver as the server separately since I use RemoteWebDriver:
/path/to/chromedriver-mac64-v2.24

Then I use ChromeOptions for the client, set the profile and binary for Opera and launch:

 capabilities = DesiredCapabilities.opera();
 ChromeOptions options = new ChromeOptions();
 options.addArguments("user-data-dir=/path/to/profile/if/needed");
 options.setBinary('/Applications/Opera.app/Contents/MacOS/Opera');
 capabilities.setCapability(ChromeOptions.CAPABILITY, options);

 driver = new RemoteWebDriver(new URL("http://127.0.0.1:9515"),capabilities);

Awesome! Works perfectly! Thank you!

So, in a nutshell, OperaDriver will never actually support Opera? We will forever be hacking ChromeDriver into running Opera instead?

commented

In the new release, v2.27, I still can't run Opera in Selenium with OperaDriver. I seem to be able to get something to happen without lying and calling it Chrome, but it still isn't working. We've gone from "session not created" to "no such session" / "Opera failed to start".

Log from the selenium node:

10:21:51.910 INFO - Selenium Grid node is up and ready to register to the hub
10:21:51.917 INFO - Starting auto registration thread. Will try to register every 5000 ms.
10:21:51.917 INFO - Registering the node to the hub: http://scrubbed/grid/register
10:21:51.924 INFO - The node is registered to the hub and ready to use
10:21:57.024 INFO - SessionCleaner initialized with insideBrowserTimeout 1200000 and clientGoneTimeout 30000 polling every 3000
10:22:24.779 INFO - Executing: [new session: Capabilities [{browserName=operablink, javascriptEnabled=true, chromeOptions={binary=/usr/bin/opera}, version=, platform=LINUX, testName=Karma test, tags=[], base=WebDriver, pseudoActivityInterval=20000}]])
10:22:24.788 INFO - Creating a new session for Capabilities [{browserName=operablink, javascriptEnabled=true, chromeOptions={binary=/usr/bin/opera}, version=, platform=LINUX, testName=Karma test, tags=[], base=WebDriver, pseudoActivityInterval=20000}]
Starting OperaDriver 2.27 (f61056e560d197467fd6d27c7fbd7fea572fe8bd) on port 19231
Only local connections are allowed.
10:23:24.797 INFO - Executing: [new session: Capabilities [{browserName=operablink, javascriptEnabled=true, chromeOptions={binary=/usr/bin/opera}, version=, platform=LINUX, testName=Karma test, tags=[], base=WebDriver, pseudoActivityInterval=20000}]])
10:23:24.798 INFO - Creating a new session for Capabilities [{browserName=operablink, javascriptEnabled=true, chromeOptions={binary=/usr/bin/opera}, version=, platform=LINUX, testName=Karma test, tags=[], base=WebDriver, pseudoActivityInterval=20000}]
Starting OperaDriver 2.27 (f61056e560d197467fd6d27c7fbd7fea572fe8bd) on port 12585
Only local connections are allowed.
10:23:24.891 INFO - Detected dialect: OSS
10:23:24.904 INFO - Done: [new session: Capabilities [{browserName=operablink, javascriptEnabled=true, chromeOptions={binary=/usr/bin/opera}, version=, platform=LINUX, testName=Karma test, tags=[], base=WebDriver, pseudoActivityInterval=20000}]]
10:23:24.935 INFO - Executing: [get title])
10:23:24.936 INFO - Executing: [get: http://localhost:9876/?id=2994973])
10:23:24.936 INFO - Executing: [get title])
10:23:24.952 WARN - Exception thrown
org.openqa.selenium.NoSuchSessionException: no such session
  (Driver info: OperaDriver=2.27 (f61056e560d197467fd6d27c7fbd7fea572fe8bd),platform=Linux 4.4.0-66-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 7 milliseconds
Build info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800'
System info: host: 'scrubbed', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-66-generic', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.opera.OperaDriver
Capabilities [{message=unknown error: Opera failed to start: exited abnormally
  (Driver info: OperaDriver=2.27 (f61056e560d197467fd6d27c7fbd7fea572fe8bd),platform=Linux 4.4.0-66-generic x86_64), platform=ANY}]
Session ID: 82b4b9791da34eb123463567a9cf3606
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:638)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:661)
        at org.openqa.selenium.remote.RemoteWebDriver.getTitle(RemoteWebDriver.java:329)
        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 org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:104)
        at com.sun.proxy.$Proxy6.getTitle(Unknown Source)
        at org.openqa.selenium.support.events.EventFiringWebDriver.getTitle(EventFiringWebDriver.java:172)
        at org.openqa.selenium.remote.server.handler.GetTitle.call(GetTitle.java:30)
        at org.openqa.selenium.remote.server.handler.GetTitle.call(GetTitle.java:22)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
10:23:24.954 WARN - Exception: no such session

Selenium node config:

{
  "capabilities": [
    {
      "browserName": "operablink",
      "maxInstances": 2,
      "seleniumProtocol": "WebDriver"
    }
  ],
  "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
  "timeout": 30,
  "browserTimeout": 1200,
  "maxSession": 4,
  "port": scrubbed,
  "host": "scrubbed",
  "register": true,
  "registerCycle": 5000,
  "hubPort": scrubbed,
  "hubHost": "scrubbed"
}