operasoftware / operachromiumdriver

OperaDriver for Chromium-based Opera releases
Other
261 stars 47 forks source link

OperaDriver should look for the Opera executable on the PATH by default #9

Open jleyba opened 9 years ago

jleyba commented 9 years ago

Attempting to create a new OperaDriver with the minimum desired capabilities ({"browserName": "opera"}) fails with:

unknown error: cannot find Opera binary
  (Driver info: OperaDriver beta=0.1.498e0af382ca0283abd01832a17569991f2ecd52,platform=Linux 3.13.0-45-generic x86_64)

Everything works if I explicitly define Opera's location:

{"browserName":"opera","chromeOptions":{"args":[],"extensions":[],"binary":"/usr/bin/opera"}}

From the about page:

Version:  27.0.1689.69 - Opera is up to date
Update stream:  Stable
System:  Ubuntu 14.04.1 LTS (x86_64; Unity)
zablotski commented 9 years ago

I have the same problem.

Version:    29.0.1795.60 - Opera is up to date
Update stream:  Stable
System: Ubuntu 14.04.2 LTS (x86_64; X-Cinnamon)
pddpp commented 9 years ago

I think I have the same issue for:

Version: 30.0.1835.55472 - Update checker is disabled Update stream: Stable System: Windows 7 64-bit (WoW64)

and need to use: {"browserName":"opera","chromeOptions":{"args":[],"extensions":[],"binary":"C:/Program Files/Opera/opera.exe"}}

t9toqwerty commented 8 years ago

Same here with Opera 34 on Ubutnu 14.04 LTS X64

Starting OperaDriver 0.2.0 (ba47709ed9e35ce26dbd960fb5d75be104290d96) on port 26860 Only local connections are allowed. Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot find Opera binary (Driver info: OperaDriver=0.2.0 (ba47709ed9e35ce26dbd960fb5d75be104290d96),platform=Linux 3.13.0-74-generic x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 4.84 seconds Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52' System info: host: 'rahul-HP-630-Notebook-PC', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-74-generic', java.version: '1.8.0_45' Driver info: org.openqa.selenium.opera.OperaDriver 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:422) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:129) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:142) at org.openqa.selenium.opera.OperaDriver.(OperaDriver.java:169) at org.openqa.selenium.opera.OperaDriver.(OperaDriver.java:137) at Opera.main(Opera.java:16) 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:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

Process finished with exit code 1

szgabsz91 commented 8 years ago

I experience the same issue with version 35 on Windows 10. I tried everything in the node configuration: operaOptions, chromeOptions, opera_binary, operablink_binary and no matter what I do, the same error is thrown:

org.openqa.selenium.WebDriverException: unknown error: cannot find Opera binary

I'd like to add Opera to my Selenium grid, but I cannot get it work. Is there an update of this error?

Thanks in advance!

ArnaudBuchholz commented 8 years ago

Same here on windows: which file are you altering to make it work?

HelioGuilherme66 commented 8 years ago

More than a year later, and no fix!

lkende commented 8 years ago

This project appears to be abandoned by Opera team.

odinho commented 8 years ago

Sorry, we are looking into this now. The developer that was responsible for this quit a year ago, and it was not picked up and taken over by someone else. Terrible procedural error there. I was responsible for nagging enough internally that we in the end started this project, so it was more of a guerilla project at the beginning and that might be why it slipped through. It's very important for us to allow people to automatically test our browser, so we're internally looking for someone who can adopt this.

I'm sorry that it has taken so long to give an answer. Do note that you can specify the opera binary by doing what issue creator wrote:

{"browserName":"opera","chromeOptions":{"args":[],"extensions":[],"binary":"/usr/bin/opera"}}

How you set these capabilities will depend on what bindings you use. But you may for instance take a look at the Chromium documentation: https://sites.google.com/a/chromium.org/chromedriver/capabilities

tnxbutno commented 7 years ago

Hi, I try examples/desktop.py and get

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Opera binary (Driver info: OperaDriver=0.2.0 (ba47709ed9e35ce26dbd960fb5d75be104290d96),platform=Linux 4.8.6-201.fc24.x86_64 x86_64)

Opera 41.0 operadriver 0.2.2 linux64

How can I fix this issue?

peiel commented 7 years ago

@tehbrut I also encountered this problem

kamillol commented 7 years ago

The same problem i have win 10 opera driver 2.29. Log:

java.lang.AssertionError: unknown error: cannot find Opera binary (Driver info: OperaDriver=0.2.0 (ba47709ed9e35ce26dbd960fb5d75be104290d96),platform=Windows NT 10.0 x86_64) (WARNING: The server did not provide any stacktrace information)

TwoD commented 7 years ago

I don't get why I have to specify the opera binary location under desired capabilities? I had major struggles getting operachromiumdriver to do anything at all because of this and when I realized my actual tests needed to specify where to find a binary on a different machine it was a huge "WTH, I have to do that??!!" moment...

I run a selenium hub which a couple of nodes connect to, all with different OS:es and browsers, and potentially different installation locations for Opera. It does not seem possible to define the location of the Opera binary on each node at all. Instead I have to make sure it's the same on all nodes and then specify the exact location in my tests, which are run from a completely separate machine!

Looking in $PATH seems like an obvious feature, but it wouldn't be an issue if there was at least possible to pass a direct parameter on launch, only accepting config via desired capabilities is completely backwards to begin with!

Since we don't have the operachromiumdriver source available and the activity here is minimal, it sadly makes issues like this really painful and unlikely to ever be fixed...

odinho commented 7 years ago

If I'm not mistaken (might be, I haven't worked for Opera in almost a year), this implementation was going to be made quite close to Chromium. So it should basically be the same code only with some patches needed to make it work. So if you want to hack on this code, do it in Chromium, and Opera will import the improvements in later.

That said, for all I know, the 'special stuff' would be exactly this. But if Chromium gets $PATH lookup (and can disthinguish say chrome and chromium), putting the support in for Opera would be quite simple. So do the work in upstream if you want TwoD :)

SalamiArmy commented 7 years ago

So this project has been abandoned by Opera team.

tatianadurova commented 7 years ago

I have the same error

`/usr/lib/jvm/java-8-openjdk-amd64/bin/java -Dmaven.multiModuleProjectDirectory=/home/yyy/repos/selenium-tests/zzzz-tests -Dmaven.home=/home/yyy/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/172.3757.29/plugins/maven/lib/maven3 -Dclassworlds.conf=/home/yyy/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/172.3757.29/plugins/maven/lib/maven3/bin/m2.conf -javaagent:/home/yyy/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/172.3757.29/lib/idea_rt.jar=39837:/home/yyy/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/172.3757.29/bin -Dfile.encoding=UTF-8 -classpath /home/yyy/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/172.3757.29/plugins/maven/lib/maven3/boot/plexus-classworlds-2.5.2.jar org.codehaus.classworlds.Launcher -Didea.version=2017.2.2 clean test -Plocal -Dbrowser=opera [INFO] Scanning for projects... [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building zzzzTests 4.0.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ zzzzTests --- [INFO] Deleting /home/yyy/repos/selenium-tests/zzzz-tests/target [INFO] [INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ zzzzTests --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 2 resources [INFO] [INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ zzzzTests --- [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 9 source files to /home/yyy/repos/selenium-tests/zzzz-tests/target/classes [INFO] /home/yyy/repos/selenium-tests/zzzz-tests/src/main/java/webdriver/WebDriverFactory.java: /home/yyy/repos/selenium-tests/zzzz-tests/src/main/java/webdriver/WebDriverFactory.java uses unchecked or unsafe operations. [INFO] /home/yyy/repos/selenium-tests/zzzz-tests/src/main/java/webdriver/WebDriverFactory.java: Recompile with -Xlint:unchecked for details. [INFO] [INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ zzzzTests --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 4 resources [INFO] [INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ zzzzTests --- [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 14 source files to /home/yyy/repos/selenium-tests/zzzz-tests/target/test-classes [INFO] /home/yyy/repos/selenium-tests/zzzz-tests/src/test/java/com/xxx/TestNgTestBase.java: Some input files use unchecked or unsafe operations. [INFO] /home/yyy/repos/selenium-tests/zzzz-tests/src/test/java/com/xxx/TestNgTestBase.java: Recompile with -Xlint:unchecked for details. [INFO] [INFO] --- automate-maven-plugin:0.7.2-SNAPSHOT:test-compile (default) @ zzzzTests --- [INFO] [INFO] --- maven-surefire-plugin:2.20:test (default-test) @ zzzzTests --- [INFO] [INFO] ------------------------------------------------------- [INFO] T E S T S [INFO] ------------------------------------------------------- [INFO] Running TestSuite ... ... TestNG 6.11 by Cédric Beust (cedric@beust.com) ...

09:37:47.900 INFO com.xxx.friendly_iframes.script_inside.FriendlyIframeTest -> Running tests on environment chrome [2017-08-16 09:37:49:207] [TestNG-tests-1] INFO BrowserManager - Latest version of [operadriver] is 2.29 [2017-08-16 09:37:49:237] [TestNG-tests-1] INFO BrowserManager - Exporting webdriver.opera.driver as /home/yyy/.m2/repository/webdriver/operadriver/linux64/2.29/operadriver 09:37:49.238 INFO webdriver.WebDriverFactory -> Running tests in local browser opera Aug 16, 2017 9:37:49 AM com.codeborne.selenide.impl.WebDriverThreadLocalContainer getWebDriver INFO: No webdriver is bound to current thread: 14 - let's create new webdriver Starting OperaDriver 2.29 (8403ff684671eab5c5d4e15ee702c893f9ecb10b) on port 3505 Only local connections are allowed. [ERROR] Tests run: 45, Failures: 1, Errors: 0, Skipped: 44, Time elapsed: 2.301 s <<< FAILURE! - in TestSuite [ERROR] setUp(com.xxx.friendly_iframes.script_inside.FriendlyIframeTest) Time elapsed: 2.176 s <<< FAILURE! org.openqa.selenium.WebDriverException: unknown error: cannot find Opera binary (Driver info: OperaDriver=2.29 (8403ff684671eab5c5d4e15ee702c893f9ecb10b),platform=Linux 4.10.0-32-generic x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 9 milliseconds Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' System info: host: 'NB0022', ip: '172.20.3.231', os.name: 'Linux', os.arch: 'amd64', os.version: '4.10.0-32-generic', java.version: '1.8.0_131' Driver info: driver.version: OperaDriver

[INFO] [INFO] Results: [INFO] [ERROR] Failures: [ERROR] FriendlyIframeTest>TestNgTestBase.setUp:72 » WebDriver unknown error: cannot f... [INFO] [ERROR] Tests run: 33, Failures: 1, Errors: 0, Skipped: 32 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 7.296 s [INFO] Finished at: 2017-08-16T09:37:49+02:00 [INFO] Final Memory: 34M/470M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20:test (default-test) on project zzzzTests: There are test failures. [ERROR] [ERROR] Please refer to /home/yyy/repos/selenium-tests/zzzz-tests/target/surefire-reports for the individual test results. [ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream. [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Process finished with exit code 1`

cezarypiatek commented 7 years ago

I was able to run my test on Opera by explicitly providing path to opera executable:

var operaOptions = new OperaOptions();
operaOptions.BinaryLocation = @"c:\Program Files\Opera\48.0.2685.52\opera.exe";

In order to not hardcode path I'm using this class to locate opera executable in runtime https://github.com/cezarypiatek/Tellurium/blob/master/Src/MvcPages/SeleniumUtils/ApplicationHelper.cs

var operaOptions = new OperaOptions();
operaOptions.BinaryLocation = ApplicationHelper.GetOperaBinaryLocation();

Probably won't work with remote driver...

SudeeptMohan commented 6 years ago

Selenium Automation-Opera Error Problem:Code throws error(log below) and program is unable to open application opera Windows : 10 Opera:49 Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot find Opera binary (Driver info: OperaDriver=2.32 (cfa164127aab5f93e5e47d9dcf8407380eb42c50),platform=Windows NT 10.0.15063 x86) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 38 milliseconds Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:26.402Z' System info: host: 'ADMIN-PC', ip: '192.168.1.6', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_151' Driver info: driver.version: OperaDriver 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.ErrorHandler.createThrowable(ErrorHandler.java:214) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166) at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53) at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91) at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$24(ProtocolHandshake.java:359) 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:362) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:136) 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:586) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:217) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:140) at org.openqa.selenium.opera.OperaDriver.(OperaDriver.java:173) at org.openqa.selenium.opera.OperaDriver.(OperaDriver.java:160) at org.openqa.selenium.opera.OperaDriver.(OperaDriver.java:115) at packageFF.browserAutomation.main(browserAutomation.java:35)

netzulo commented 6 years ago

i am at the same point :(

and can't deduce real problem, i was thinking about this test set, what do you think about this ?

@jleyba @zablotski @pddpp @t9toqwerty @szgabsz91 , @bharath588

Manuals

Need to test combinations for

  1. env var command lane -Dopera.binary= and -Dwebdriver.opera.driver= -->
  2. node browser name opera and operablink -->
  3. python remote browser name opera and operablink
skimleary commented 6 years ago

Turns out as of OperaDriver 2.33 for Linux, it is looking for opera-developer and not opera. I made a link in /usr/bin: ln -s opera opera-developer and my tests are working now.

buscseik commented 6 years ago

I use opera driver over selenium2library in RobotFramework. Is there a work around for robot framework also?

skimleary commented 6 years ago

@buscseik, et al., I should have included my test environment. I'm using RobotFramework on OS X and Linux. RF works right out of the box on OS X with operadriver in my PATH. For Linux (RHEL7 in this case), operadriver also needs to be in my PATH, but I also had to make the soft link as above because the Linux version of operadriver is looking for the opera-developer executable, NOT opera.

buscseik commented 6 years ago

I tried to load from python and following error pop up. It seems the path being handled incorrectly. The "\51" in the path being replaced by ")" "\51." is in line 5 ")" is in line 23

Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from selenium import webdriver
>>> options = webdriver.ChromeOptions()
>>> options.binary_location = "c:\Program Files\Opera\51.0.2830.40\opera.exe"
>>> driver = webdriver.Opera(options=options)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python36\lib\site-packages\selenium\webdriver\opera\webdriver.py", line 78, in __init__
    service_log_path=service_log_path)
  File "C:\Python36\lib\site-packages\selenium\webdriver\opera\webdriver.py", line 57, in __init__
    service_log_path=service_log_path)
  File "C:\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 75, in __init__
    desired_capabilities=desired_capabilities)
  File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 154, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 243, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
    self.error_handler.check_response(response)
  File "C:\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: no Opera binary at c:\Program Files\Opera).0.2830.40\opera.exe
  (Driver info: OperaDriver=2.32 (cfa164127aab5f93e5e47d9dcf8407380eb42c50),platform=Windows NT 10.0.16299 x86_64)
As you can see the "\51." in the path has been miss interpreted into ")" in the defined path
skimleary commented 6 years ago

@buscseik, While I'm not an Windows programmer, please know that Python is Unix-oriented. So, in that vein, please turn all your backslashes into forward slashes (in the options.binary_location assignment), then give it another go. I'm not sure if that will work, but... If that doesn't work, try restoring the backslashes, and replace the double quotes in the assignment to single quotes, instead. That will eliminate the escape sequence exception that is being thrown at you: "\51" => ")".

buscseik commented 6 years ago

Unfortunately this is not possible. The Robot framework module use the PATH environment variable to locate opera. So this happen automatically. On other and, the "/" is not valid character in PATH environment variable.

gajulapallibharath-reddy-empower commented 6 years ago

We can run opera by using below code in local machine, System.setProperty("webdriver.opera.driver",".\browserDrivers\operadriver.exe"); DesiredCapabilities capabilities = new DesiredCapabilities(); OperaOptions options = new OperaOptions(); options.setBinary("C:\Program Files\Opera\51.0.2830.40\Opera.exe"); capabilities.setCapability(OperaOptions.CAPABILITY, options); OperaDriver driver = new OperaDriver(capabilities);

Opera Binary Path : C:\Program Files\Opera\51.0.2830.40\Opera.exe But it is not possible to set path in Grid/ Remote Driver. path might vary from machine to machine, can some one please help me on this. thank you in advance.

BookGin commented 6 years ago

@bharath588 's solution works for me.

In case that someone is looking for the Python version of the workaround:

#!/usr/bin/env python3
# selenium 3.14.1, Python 3.7.0

from selenium import webdriver

options = webdriver.ChromeOptions()
options.binary_location = "/usr/bin/opera"

# and make sure you have operadriver in PATH
driver = webdriver.Opera(options=options)
driver.get('https://example.com')
print(driver.title)
netzulo commented 6 years ago

@BookGin , ty ! working for me too!

Vic-Din commented 4 years ago

Operadriver on a Mac:

  1. Create a directory to place the executables in, like /documents/my_project/bin
  2. Add the directory to your PATH In a terminal: export PATH=$PATH:/documents/my_project/bin >> ~/.profile

If a operadriver complains it does not have the correct permission, you need to grant it a numerical permission equivalent to or greater than 755 (664 is the default):

  1. cd to your working directory
  2. $ chmod 755 operadriver - to allow your program to manipulate it

Or you can programmatically change the permission of operadriver in your Python script using:

import os
os.chmod('/documents/my_project/bin', 0o755)