Selenium Python:如何在Opera中打开默认配置文件

3
我该如何在Opera中打开默认配置文件? 我指的是与打开独立的Opera时相同的配置文件。 以下代码只会以新的配置文件打开:
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)
1个回答

3
基本上,您可以像在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)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接