Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

selenium python: open default profile in opera

How do I open the default profile in Opera? I mean the same profile as when I open the stand along Opera. This code just opens up with a new profile:

import os
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
os.environ["SELENIUM_SERVER_JAR"] = '/home/brian/bin/selenium-server-standalone-2.37.0.jar'
capabilities = DesiredCapabilities.OPERA
capabilities['opera.profile'] = ''  
browser = webdriver.Opera(desired_capabilities=capabilities)
like image 499
brian Avatar asked Jul 25 '26 19:07

brian


1 Answers

Basically, you set the profile the same way you do with Chrome.

from selenium import webdriver
opera_profile = 'C:\\Users\\<username>\\AppData\\roaming\Opera software\\Opera Stable'  # relevant for Windows 7 and above
options = webdriver.ChromeOptions()
options.add_argument('user-data-dir=' + opera_profile)
opera_driver = webdriver.Opera(executable_path=<path_to_operadriver>, opera_options=options)
like image 92
whats_done_is Avatar answered Jul 27 '26 09:07

whats_done_is



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!