Skip to content

Latest commit

 

History

History
68 lines (52 loc) · 1.98 KB

desktop.md

File metadata and controls

68 lines (52 loc) · 1.98 KB

Desktop

For now to drive the Chromium-based Opera you’ll need to use the RemoteWebDriver. Python examples are provided below. For other languages please refer to the Selenium docs.

Creating an OperaDriver service

# Create and start OperaDriver service:
from selenium.webdriver.chrome import service
webdriver_service = service.Service(opera_driver_exe_path,
                                        port_on_which_service_will_be_running)
webdriver_service.start()

Creating a remote webdriver for selenium 4

# Create OperaDriver options:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.binary_location = opera_exe_path
options.add_experimental_option('w3c', True)
# Create remote webdriver
remote = webdriver.Remote(webdriver_service.service_url, options=options)

Creating a remote webdriver for selenium 2, 3

# Create remote webdriver:
from selenium import webdriver
remote = webdriver.Remote(webdriver_service, capabilities)

Depending on capabilites OperaDriver may be connected to the browser in several ways.

  1. Let the driver start a given Opera executable.
capabilities = {
    'operaOptions': {
        'binary': opera_exe_path
    }
}
  1. Let the driver auto-detect the Opera executable’s location and start it.
capabilities = { }
  1. Attach to the existing Opera instance. This requires running Opera with --remote-debugging-port=port.
capabilities = {
    'operaOptions': {
        'debuggerAddress': port # Same port as passed to the Opera.
    }
}

Browser options

As OperaDriver is based on ChromeDriver, it has similar supported options. You can also set the path where browser logs will be stored using the logPath option.