operasoftware / operachromiumdriver

OperaDriver for Chromium-based Opera releases
Other
257 stars 52 forks source link

" cannot find Opera binary" error in python3.6.5 #64

Open SCF123 opened 5 years ago

SCF123 commented 5 years ago

Firstly,I write the code.

from selenium import webdriver driver = webdriver.Opera() driver.get('https://www.seleniumhq.org/') driver.quit()

I got the following error message. D:\Python36\python.exe C:/Users/Administrator/Desktop/test1.py Traceback (most recent call last): File "C:/Users/Administrator/Desktop/test1.py", line 7, in <module> driver = webdriver.Opera() File "D:\Python36\lib\site-packages\selenium\webdriver\opera\webdriver.py", line 83, in __init__ service_log_path=service_log_path) File "D:\Python36\lib\site-packages\selenium\webdriver\opera\webdriver.py", line 62, in __init__ keep_alive=keep_alive) File "D:\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in __init__ desired_capabilities=desired_capabilities) File "D:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__ self.start_session(capabilities, browser_profile) File "D:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "D:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "D:\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: cannot find Opera binary (Driver info: OperaDriver=2.41,platform=Windows NT 10.0.16299 x86_64)

After that,I wrote the following code again.

from selenium import webdriver options = webdriver.ChromeOptions() options.binary_location = "D:\Python36\operadriver.exe" driver = webdriver.Opera(options=options) driver.get('https://www.seleniumhq.org/') driver.quit()

It still gives me an error! D:\Python36\python.exe C:/Users/Administrator/Desktop/test1.py Traceback (most recent call last): File "C:/Users/Administrator/Desktop/test1.py", line 6, in <module> driver = webdriver.Opera(options=options) File "D:\Python36\lib\site-packages\selenium\webdriver\opera\webdriver.py", line 83, in __init__ service_log_path=service_log_path) File "D:\Python36\lib\site-packages\selenium\webdriver\opera\webdriver.py", line 62, in __init__ keep_alive=keep_alive) File "D:\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in __init__ desired_capabilities=desired_capabilities) File "D:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__ self.start_session(capabilities, browser_profile) File "D:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "D:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "D:\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: Opera failed to start: was killed (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location D:\Python36\operadriver.exe is no longer running, so OperaDriver is assuming that Opera has crashed.) (Driver info: OperaDriver=2.41,platform=Windows NT 10.0.16299 x86_64) Who can tell me how to solve the error?

version: python:3.6.5 selenium:3.141.0 opera: 57.0.3098.91 operadriver: 2.41 platform: Windows NT 10.0.16299 x86_64

bgmafia commented 5 years ago

you should set your service to point to the webdriver ( in your case ""D:\Python36\operadriver.exe") and your binary_location to point to the opera.exe file ( for example D:\Opera\58.0.3135.53\opera.exe ).

fenchu commented 5 years ago

I have the same issue, reason is that launcher.exe is the one that gets into path. Before running add it to your path: $env:PATH="$($env:PATH);" + "C:\Users\mobj\AppData\Local\Programs\Opera\60.0.3255.170\"