设置 Selenium Firefox 配置文件
Setting up Selenium Firefox profile
运行 在我们的测试中,我们遇到了一个与 FireFox 在浏览器没有焦点时管理事件的方式有关的问题。
我们发现通过将首选项 "focusmanager.testmode" 设置为 true (https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/157) 来设置 FireFox 配置文件可以解决此问题。
我的问题是,您是否知道任何其他 preference/capability/whatever 值得我们 profile/configuration 的网络驱动程序使用?
这可以为我们在以后调试奇怪的东西时节省很多时间problems/behaviours,如果你能给我任何建议,我将不胜感激。
Firefox 有各种可以调整以提高测试稳定性的首选项。但正如 所指出的那样,更改任何内容都可能会影响您的测试,因此,这可能不是一个最好的主意。
无论如何,这是我用来减少由于意外的浏览器行为而导致测试失败的一组首选项:
// Disable checking if firefox is default browser
lockPref('browser.shell.checkDefaultBrowser', false);
// Disable restoring session
lockPref('browser.sessionstore.resume_from_crash', false);
// Disable updater
lockPref("app.update.enabled", false);
// make absolutely sure it is really off
lockPref("app.update.auto", false);
lockPref("app.update.mode", 0);
lockPref("app.update.service.enabled", false);
// Prevent closing dialogs
lockPref("browser.showQuitWarning", false);
lockPref("browser.warnOnQuit", false);
lockPref("browser.tabs.warnOnClose", false);
lockPref("browser.tabs.warnOnCloseOtherTabs", false);
// Disable Add-ons compatibility checking
clearPref("extensions.lastAppVersion");
// Don't show 'know your rights' on first run
pref("browser.rights.3.shown", true);
//Disable plugin checking
lockPref("plugins.hide_infobar_for_outdated_plugin", true);
clearPref("plugins.update.url");
// Disable health reporter
lockPref("datareporting.healthreport.service.enabled", false);
// Disable all data upload (Telemetry and FHR)
lockPref("datareporting.policy.dataSubmissionEnabled", false);
// Disable crash reporter
lockPref("toolkit.crashreporter.enabled", false);
Components.classes["@mozilla.org/toolkit/crash-reporter;1"].getService(Components.interfaces.nsICrashReporter).submitReports = false;
// Browser Console command line
pref("devtools.chrome.enabled", true);
要使设置首选项的过程自动化,您可能喜欢使用所谓的 Firefox 自动配置文件。
示例配置:https://github.com/cliqz-oss/firefox-autoconfigs
只是为了跟进我的评论,我非常反对拥有一组自定义首选项/配置文件设置:
- 尽量减少测试内容与普通用户看到的内容之间的差异
- 最小化浏览器特定代码
- 此外,它可以使诊断此类网站上的问题变得更加复杂
换句话说,我希望 Firefox(等)成为一个黑盒子。
我完全支持 Firefox 的错误得到修复,甚至默认行为可能会随着时间的推移而演变,前提是每个人都是 "on the same page"。我认为测试已经足够复杂,无需人们选择不同的解决方法。
运行 在我们的测试中,我们遇到了一个与 FireFox 在浏览器没有焦点时管理事件的方式有关的问题。
我们发现通过将首选项 "focusmanager.testmode" 设置为 true (https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/157) 来设置 FireFox 配置文件可以解决此问题。
我的问题是,您是否知道任何其他 preference/capability/whatever 值得我们 profile/configuration 的网络驱动程序使用?
这可以为我们在以后调试奇怪的东西时节省很多时间problems/behaviours,如果你能给我任何建议,我将不胜感激。
Firefox 有各种可以调整以提高测试稳定性的首选项。但正如
无论如何,这是我用来减少由于意外的浏览器行为而导致测试失败的一组首选项:
// Disable checking if firefox is default browser
lockPref('browser.shell.checkDefaultBrowser', false);
// Disable restoring session
lockPref('browser.sessionstore.resume_from_crash', false);
// Disable updater
lockPref("app.update.enabled", false);
// make absolutely sure it is really off
lockPref("app.update.auto", false);
lockPref("app.update.mode", 0);
lockPref("app.update.service.enabled", false);
// Prevent closing dialogs
lockPref("browser.showQuitWarning", false);
lockPref("browser.warnOnQuit", false);
lockPref("browser.tabs.warnOnClose", false);
lockPref("browser.tabs.warnOnCloseOtherTabs", false);
// Disable Add-ons compatibility checking
clearPref("extensions.lastAppVersion");
// Don't show 'know your rights' on first run
pref("browser.rights.3.shown", true);
//Disable plugin checking
lockPref("plugins.hide_infobar_for_outdated_plugin", true);
clearPref("plugins.update.url");
// Disable health reporter
lockPref("datareporting.healthreport.service.enabled", false);
// Disable all data upload (Telemetry and FHR)
lockPref("datareporting.policy.dataSubmissionEnabled", false);
// Disable crash reporter
lockPref("toolkit.crashreporter.enabled", false);
Components.classes["@mozilla.org/toolkit/crash-reporter;1"].getService(Components.interfaces.nsICrashReporter).submitReports = false;
// Browser Console command line
pref("devtools.chrome.enabled", true);
要使设置首选项的过程自动化,您可能喜欢使用所谓的 Firefox 自动配置文件。 示例配置:https://github.com/cliqz-oss/firefox-autoconfigs
只是为了跟进我的评论,我非常反对拥有一组自定义首选项/配置文件设置:
- 尽量减少测试内容与普通用户看到的内容之间的差异
- 最小化浏览器特定代码
- 此外,它可以使诊断此类网站上的问题变得更加复杂
换句话说,我希望 Firefox(等)成为一个黑盒子。
我完全支持 Firefox 的错误得到修复,甚至默认行为可能会随着时间的推移而演变,前提是每个人都是 "on the same page"。我认为测试已经足够复杂,无需人们选择不同的解决方法。