Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Opera on Windows via RemoteWebDriver: org.openqa.selenium.WebDriverException: Could not find a runtime for script injection #2470

Closed
lukeis opened this issue Mar 3, 2016 · 10 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 2470

I'm trying to run Opera on Windows from Java via RemoteWebDriver. When I run my test,
I see Opera open, then almost immediately the test fails with an exception. I'm running
the grid node from a Windows command window as Administrator, and although I don't
think I'm supposed to need to, I've set an environment variable in Windows as: OPERA_PATH="C:\Program
Files\Opera\"

A very similar test works great on Mac OS X, but not Windows 7.

I haven't tried to set up OperaDriver.exe because I think that since I'm using selenium-server-standalone-2.6.0,
I don't need to (seems to be true on Mac OS X).

Apologies if this is the wrong place to try to find out why what I'm trying is not
working, or if I missed some step documented somewhere.

The version of Opera on Windows:
    Version
    11.51

    Build
    1087

    Platform
    Win32

    System
    Windows 7

    XHTML+Voice
    Plug-in not loaded

    Browser identification

    Opera/9.80 (Windows NT 6.1; U; Edition United States Local; en) Presto/2.9.168 Version/11.51

My RemoteWebDriver instantiation code:
    DesiredCapabilities capability = DesiredCapabilities.opera();
    capability.setBrowserName("opera");
    capability.setCapability("platform", "WINDOWS");
    capability.setVersion("11");
    log.info("Starting Opera 10 (v 11.51) browser for Windows 7");
    WebDriver myOperaDriver = new RemoteWebDriver(new URL(
            "http://localhost:4444/wd/hub"), capability);

The code to run a grid node on Windows 7:
    Java -jar selenium-server-standalone-2.6.0.jar -role webdriver -hub http://%ip%:4444/grid/registor
-port 5564 -maxSession 5 -browser browserName="opera",platform=WINDOWS,version=11,maxInstances=1
ensureCleanSession=true registerCycle=10000

MVN dependencies, pom.xml entries:
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.6.0</version>
    </dependency>

Here's the whole exception message:

org.openqa.selenium.WebDriverException: Could not find a runtime for script injection
Build info: version: '2.6.0', revision: '13840', time: '2011-09-13 14:55:30'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version:
'1.6.0_27'
Driver info: driver.version: OperaDriver; duration or timeout: 31.84 seconds
Build info: version: '2.6.0', revision: '13840', time: '2011-09-13 16:51:41'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.6.8', java.version:
'1.6.0_26'
Driver info: driver.version: RemoteWebDriver

Longer version from where the grid node is running:
15:03:02.363 INFO - Done: /status
15:03:02.472 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.6.0', revision: '13840', time: '2011-09-13 14:55:30'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version:
'1.6.0_27'
Driver info: driver.version: unknown
        at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source)
        at java.util.concurrent.FutureTask.get(Unknown Source)
        at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:118)
        at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:89)
        at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:74)
        at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:87)
        at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:48)
        at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:166)
        at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:450)
        at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:432)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
        at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:677)
        at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
        at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1530)
        at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1482)
        at org.openqa.jetty.http.HttpServer.service(HttpServer.java:909)
        at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
        at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
        at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
        at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
        at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357)
        at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.6.0', revision: '13840', time: '2011-09-13 14:55:30'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version:
'1.6.0_27'
Driver info: driver.version: unknown
        at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructor(DefaultDriverFactory.java:98)
        at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:82)
        at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:156)
        at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
        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.server.DefaultDriverFactory.callConstructor(DefaultDriverFactory.java:88)
        ... 8 more
Caused by: org.openqa.selenium.WebDriverException: org.openqa.selenium.WebDriverException:
Could not find a runtime for script injection
Build info: version: '2.6.0', revision: '13840', time: '2011-09-13 14:55:30'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version:
'1.6.0_27'
Driver info: driver.version: OperaDriver
Build info: version: '2.6.0', revision: '13840', time: '2011-09-13 14:55:30'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version:
'1.6.0_27'
Driver info: driver.version: OperaDriver
        at com.opera.core.systems.OperaDriver.start(OperaDriver.java:343)
        at com.opera.core.systems.OperaDriver.<init>(OperaDriver.java:293)
        ... 13 more
Caused by: org.openqa.selenium.WebDriverException: Could not find a runtime for script
injection
Build info: version: '2.6.0', revision: '13840', time: '2011-09-13 14:55:30'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version:
'1.6.0_27'
Driver info: driver.version: OperaDriver
        at com.opera.core.systems.scope.services.ums.EcmaScriptDebugger.init(EcmaScriptDebugger.java:164)
        at com.opera.core.systems.ScopeServices.initializeServices(ScopeServices.java:274)
        at com.opera.core.systems.ScopeServices.init(ScopeServices.java:250)
        at com.opera.core.systems.OperaDriver.init(OperaDriver.java:360)
        at com.opera.core.systems.OperaDriver.start(OperaDriver.java:339)
        ... 14 more
15:03:02.488 WARN - Exception: Could not find a runtime for script injection
Build info: version: '2.6.0', revision: '13840', time: '2011-09-13 14:55:30'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version:
'1.6.0_27'
Driver info: driver.version: OperaDriver
15:03:02.753 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@1a1399
at URL: /status)
15:03:02.753 INFO - Executing: org.openqa.selenium.remote.server.handler.Status@1a1399
at URL: /status)
15:03:02.753 INFO - Done: /status


Reported by APailthorp on 2011-09-15 22:05:55

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Andreas, can you look at this?

Reported by jari.bakken on 2011-09-18 12:07:02

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

“Could not find a runtime for script injection” means that the currently activated tab/document
isn't script injectable; that OperaDriver isn't able to inject JavaScript to the document.

This is true for certain types of pages in Opera, such as "opera:about" and some error
pages (protocol not supported comes into mind).

Can you open Opera manually and close all open tabs, then try again?

Also OperaDriver is written completely in Java, so you don't need to set up any executable
(OperaDriver.exe).  Everything should work out of the box from Selenium v2.6.

You shouldn't have to set OPERA_PATH for getting it to work.  If you unset it, it will
guess the path to your Opera.  If you've installed Opera to a non-standard location,
consider using .setCapability("opera.binary", "/path/to/my/opera") instead.

Reported by andreas.tolf.tolfsen on 2011-09-18 12:48:01

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Thank you for having a look at the issue.

Setting OPERA_PATH wsa an effort to work around this issue. The test is an example
to try and get Grid doing what I want, it is operating against Google, just clicking
around on a few screens. It may be relevant that the first page that the Opera installation
opens is some kind of Opera debug page. I'll try to get more specifics in here later.
The same test runs against other WebDriver instanciations without error, including
Opera on Mac OS X. I will try manual operation of the browser and report back. I should
also mention that my Grid node is running on a Windows 7 install that is running on
a Paralles VM on the same Mac.

More later. Thanks again.

Reported by APailthorp on 2011-09-18 14:30:52

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Okay, it is the Opera About page that is opening, but I'm having a heck of a time getting
to it to open it manually and close the tab. When I operate Opera manually, it comes
up with the expected home page. I tried debugging to get to the session manually, but
the browser opens and closes pretty quick, not sure how to step to just the open.

Perhaps because Opera is running a Administrator profile. I will try logging into Windows
as Administrator rather than just using Opera from a Grid node running from an Administrator
command session.

If there is a manual way to reset or delete the profile Opera must be using to get
the About and some other tab (looks like Google Gmail), that might be another way to
clear the issue.

Reported by APailthorp on 2011-09-18 15:20:30

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

That was the problem, I'm now running as expected. I guess this was an artifact of a
work around for another issue, needing to run as Administrator (and not just an account
with Administrator privileges) and as a consequence having an incorrectly established
profile.

Thanks!

Reported by APailthorp on 2011-09-18 15:49:59

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Opera is launched from OperaDriver using the -autotestmode switch.  Currently this creates
an autotestmode profile somewhere in C:\Program Files\Opera.  If you launcher Opera
manually without this option, you won't run on the autotestmode profile, which won't
show any open tabs from that session.

Hopefully, in the next version of Opera, we will have support for the -pd switch. 
This will allow us to instruct Opera to use any profile of our choice.  This should
vastly improve test stability, especially on Windows where you currently have to run
your tests on the Administrator account because the autotestmode profile is located
in a write-protected directory if Opera is installed to the default location.

Thanks for reporting this issue, though!  We're working hard on getting proper Grid
support for Opera.  The next Opera version will also make it possible to parallelize
several instances of Opera.

Reported by andreas.tolf.tolfsen on 2011-09-19 09:47:34

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by barancev on 2011-10-04 07:49:05

  • Labels added: Component-WebDriver

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by stuidge on 2011-10-04 10:35:24

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by andreas.tolf.tolfsen on 2011-10-04 13:00:42

  • Status changed: Fixed

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by luke.semerau on 2015-09-17 18:13:45

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 3, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant