mercredi 27 août 2014

Selenium WebDriver ; Les "user pref" (ex : pour modifier le User Agent)

En C#, modifiables par exemple comme ceci :
private IWebDriver GetFirefoxDriver() { FirefoxProfile profile = new FirefoxProfile(); profile.SetPreference("general.useragent.override", CustomUserAgent.Firefox31UserAgent1); return new FirefoxDriver(profile); } public static class CustomUserAgent { public static string Firefox31UserAgent1 = "Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0"; }
La liste (disponible sur Windows dans le répertoire suivant par exemple) : C:\Users\[Utilisateur]\AppData\Local\Temp\anonymous.7e548eeaffbc4ad5ac7eb557795ad7f1.webdriver-profile\
user_pref("app.update.auto", false); user_pref("app.update.enabled", false); user_pref("browser.download.manager.showWhenStarting", false); user_pref("browser.EULA.override", true); user_pref("browser.EULA.3.accepted", true); user_pref("browser.link.open_external", 2); user_pref("browser.link.open_newwindow", 2); user_pref("browser.offline", false); user_pref("browser.safebrowsing.enabled", false); user_pref("browser.safebrowsing.malware.enabled", false); user_pref("browser.search.update", false); user_pref("browser.sessionstore.resume_from_crash", false); user_pref("browser.shell.checkDefaultBrowser", false); user_pref("browser.tabs.warnOnClose", false); user_pref("browser.tabs.warnOnOpen", false); user_pref("devtools.errorconsole.enabled", true); user_pref("dom.disable_open_during_load", false); user_pref("extensions.autoDisableScopes", 10); user_pref("extensions.blocklist.enabled", false); user_pref("extensions.logging.enabled", true); user_pref("extensions.update.enabled", false); user_pref("extensions.update.notifyUser", false); user_pref("layout.css.devPixelsPerPx", "1.0"); user_pref("network.manage-offline-status", false); user_pref("network.http.phishy-userpass-length", 255); user_pref("offline-apps.allow_by_default", true); user_pref("prompts.tab_modal.enabled", false); user_pref("security.csp.enable", false); user_pref("security.fileuri.origin_policy", 3); user_pref("security.fileuri.strict_origin_policy", false); user_pref("security.warn_entering_secure", false); user_pref("security.warn_entering_secure.show_once", false); user_pref("security.warn_entering_weak", false); user_pref("security.warn_entering_weak.show_once", false); user_pref("security.warn_leaving_secure", false); user_pref("security.warn_leaving_secure.show_once", false); user_pref("security.warn_submit_insecure", false); user_pref("security.warn_viewing_mixed", false); user_pref("security.warn_viewing_mixed.show_once", false); user_pref("signon.rememberSignons", false); user_pref("toolkit.networkmanager.disable", true); user_pref("toolkit.telemetry.prompted", 2); user_pref("toolkit.telemetry.enabled", false); user_pref("toolkit.telemetry.rejected", true); user_pref("browser.dom.window.dump.enabled", true); user_pref("browser.newtab.url", "about:blank"); user_pref("browser.newtabpage.enabled", false); user_pref("browser.startup.page", 1); user_pref("browser.startup.homepage", "about:blank"); user_pref("dom.max_chrome_script_run_time", 30); user_pref("dom.max_script_run_time", 30); user_pref("dom.report_all_js_exceptions", true); user_pref("javascript.options.showInConsole", true); user_pref("network.http.max-connections-per-server", 10); user_pref("startup.homepage_welcome_url", ""); user_pref("webdriver_accept_untrusted_certs", true); user_pref("webdriver_assume_untrusted_issuer", true); user_pref("general.useragent.override", "Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0"); user_pref("webdriver_firefox_port", 7055); user_pref("webdriver_enable_native_events", true);