Issue
I'm trying selenium on Opera browser and I keep getting this error.
I have tried using the service
kwarg but I just keep getting TypeError: WebDriver.__init__() got an unexpected keyword argument 'service'
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
service = Service(r'path\to\operadriver.exe')
driver = webdriver.Opera(service)
Solution
You can see here from the documentation of the WebDriver API (https://selenium-python.readthedocs.io/api.html#module-selenium.webdriver.opera.webdriver):
__init__(executable_path=None, port=0, options=None, service_args=None, desired_capabilities=None, service_log_path=None, opera_options=None, keep_alive=True)
Creates a new instance of the operadriver.
Starts the service and then creates new instance of operadriver.
Args:
executable_path - path to the executable. If the default is used
it assumes the executable is in the $PATH
port - port you would like the service to run, if left as 0,
a free port will be found.
options: this takes an instance of OperaOptions
service_args - List of args to pass to the driver service
desired_capabilities: Dictionary object with non-browser specific
service_log_path - Where to log information from the driver.
opera_options - Deprecated argument for options capabilities only, such as “proxy” or “loggingPref”.
The webdriver.Opera doesn't have a service object parameter.
Instead you can check this example here:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.binary_location ="<your opera executable directory>"
driver = webdriver.Opera(options=options)
driver.get("https://www.facebook.com")
# make sure 'operadriver.exe' is in the same folder as your directory
Answered By - Bemwa Malak
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.