Home > Enterprise >  Selenium, how do you instinatiate Opera webdriver using Python?
Selenium, how do you instinatiate Opera webdriver using Python?

Time:10-25

For firefox,chrome,safarim,edge it works smth like this:

driver_instance = webdriver.Chrome(chrome_options=chrome_options)

But I can't find information on how to do the same for the Opera web driver and apparently it's supported. I downloaded the Opera webdriver, put it in my PATH but what command I'm supposed to run to make it run in Opera?

CodePudding user response:

You can use below code to initiate opera browser

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.opera.options import Options

options = Options()
options.binary_location = r'location_of_opera.exe'
driver = webdriver.Opera(options=options, executable_path=r' location_of_operadriver.exe')
driver.maximize_window()
driver.get("https://www.google.com")

CodePudding user response:

Download opera driver here: https://github.com/operasoftware/operachromiumdriver/releases

And use like this:

options.binary_location = r'location_of_opera.exe'
self.driver = webdriver.Opera(options=options, executable_path=r'location_of_operadriver.exe')

Example:Example

  • Related