Skip to content Skip to sidebar Skip to footer

Unable To Launch Opera Using Python Selenium

I am trying to launch opera using python selenium libraries. But getting capabilities error. Codes I have tried: Code1: driver = webdriver.Opera() driver.get('https://www.google.co

Solution 1:

This error message...

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Opera binary

and this error message...

selenium.common.exceptions.WebDriverException: Message: DesiredCapabilitiesmustbeadictionary

and this error message...

[20904:3220:0120/034255.122:ERROR:os_crypt_win.cc(61)] Failed to decrypt: The parameter is incorrect. (0x57)

...implies that the OperaDriver was unable to initiate/spawn a new Browsing Context i.e. Opera Browser session.


Solution

First of all you need to ensure that, you have downloaded the latest OperaChromiumDriver from operasoftware / operachromiumdriver. As per OperaDriver for Chromium-based Opera releases:

OperaChromiumDriver is a WebDriver implementation derived from ChromeDriver and adapted by Opera that enables programmatic automation of Chromium-based Opera products for desktop and Android platforms. It is a part of the Selenium project.

OperaChromiumDriver can be used without extra setup on Chromium-based versions of Opera starting from version 26.

Use both the arguments:

  • binary_location for opera binary and
  • executable_path for operadriver binary
  • Code Block:

    from selenium import webdriver
    from selenium.webdriver.opera.options import Options
    
    options = Options()
    options.binary_location = r'C:\Opera\launcher.exe'
    driver = webdriver.Opera(options=options, executable_path=r'C:\path\to\operadriver.exe')
    driver.get("http://google.com/")
    

Solution 2:

This worked for me:

from selenium import webdriver
from selenium.webdriver.opera.optionsimportOptions

options = Options()
driver = webdriver.Opera(options=options)
driver.get("https://www.google.com")

I also get the same errors you showed but the URLs I need to open are being loaded automatically in Opera without issue.

You need to make sure your opera version matches the version of the driver. check it by opening opera and enter this: opera://about Ensure the operadriver.exe is on the same folder of the python script.

The driver can be downloaded here: https://github.com/operasoftware/operachromiumdriver/releases

Post a Comment for "Unable To Launch Opera Using Python Selenium"