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.
# Create OperaDriver service:
from selenium.webdriver.chrome import service
webdriver_service = service.Service(opera_driver_exe_path,
port_on_which_service_will_be_running)
# 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.
- Let the driver start a given Opera executable.
capabilities = {
'operaOptions': {
'binary': opera_exe_path
}
}
- Let the driver auto-detect the Opera executable’s location and start it.
capabilities = { }
- 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.
}
}
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.