【发布时间】:2019-07-12 12:04:17
【问题描述】:
我手动创建了一个包含插件/扩展(Hotspot Shield VPN 插件)的特定 Firefox 配置文件。现在,在代码中,我通过 firefox 驱动程序加载此配置文件,但问题是从代码启动时未加载扩展。另一方面,手动启动配置文件时它工作得很好。
var profileManager = new FirefoxProfileManager();
var profile = profileManager.GetProfile("brysontiller");
profile.SetPreference("extensions.allowPrivateBrowsingByDefault", true);
profile.SetPreference("extensions.hotspot-shield@anchorfree.com.onByDefault", true);
var options = new FirefoxOptions { Profile = profile, LogLevel = FirefoxDriverLogLevel.Trace };
var driver = new FirefoxDriver(@"C:\Users\danza\source\repos\InstaManager\", options);
driver.Navigate().GoToUrl("https://www.google.com");
我尝试在代码中添加扩展名
profile.AddExtension(@"C:\Users\danza\AppData\Roaming\Mozilla\Firefox\Profiles\652o40ny.profile_7\extensions\hotspot-shield@anchorfree.com.xpi");
这行代码仍然存在上述问题。 (虽然这并不是真正需要的,因为手动创建的配置文件已经包含所需的扩展名,因此无需再次添加)。
我还尝试设置各种配置文件首选项,如下所示:
profile.SetPreference("extensions.allowPrivateBrowsingByDefault", true);
profile.SetPreference("extensions.hotspot-shield@anchorfree.com.onByDefault", true);
问题仍然存在。
当我手动启动配置文件时加载加载项,如下所示:
但是当我通过代码启动它时,它不会:
【问题讨论】:
标签: c# selenium geckodriver