如何通过 Selenium WebDriver 关闭 Firefox 浏览器的“增强跟踪保护”?

Aut*_*999 5 java firefox selenium selenium-webdriver

我的 Selenium Java 测试脚本在 Firefox 浏览器上运行。

最近,它开始在打开“增强跟踪保护”的应用程序上失败。

https://support.mozilla.org/en-US/kb/enhanced-tracking-protection-firefox-desktop

如何通过 Selenium Web 驱动程序禁用/关闭它?是否有任何首选项或功能可以让我在 Firefox 配置文件中将其关闭?

小智 2

我将 Selenium 与 PowerShell 一起使用,并且遇到了同样的问题。这个解决方案对我有用

[OpenQA.Selenium.Firefox.FirefoxProfileManager]$ProfileManager= [OpenQA.Selenium.Firefox.FirefoxProfileManager]::new()
[OpenQA.Selenium.Firefox.FirefoxProfile]$FirefoxProfile = $ProfileManager.GetProfile($ProfileName)

$FirefoxProfile.SetPreference("pref.privacy.disable_button.tracking_protection_exceptions", $true)
Run Code Online (Sandbox Code Playgroud)