Saturday, November 15, 2008

Customize Selenium Chrome TestRunner profile in JRunner

There is a prefs.js configuration file for each Firefox profile.
Selenium Java Runner can do some necessary customization before launch Firefox TestRunner instance.
Read prefs.js docs: http://kb.mozillazine.org/Prefs.js_file

Sample prefs.js customize code:
PrintStream out = new PrintStream(new FileOutputStream(prefsJS, true));
// Don't ask if we want to switch default browsers
out.println("user_pref('browser.shell.checkDefaultBrowser', false);"); 
// suppress authentication confirmations
out.println("user_pref('network.http.phishy-userpass-length', 255);");
// Disable pop-up blocking
out.println("user_pref('browser.allowpopups', true);");
out.println("user_pref('dom.disable_open_during_load', false);");
out.println("user_pref('startup.homepage_welcome_url', '');");
// Disable Restore your session dialog. Always start a new session
out.println("user_pref('browser.sessionstore.enabled', false);");
// Disable security warnings
out.println("user_pref('security.warn_submit_insecure', false);");
out.println("user_pref('security.warn_submit_insecure.show_once', false);");
out.println("user_pref('security.warn_entering_secure', false);");
out.println("user_pref('security.warn_entering_secure.show_once', false);");
out.println("user_pref('security.warn_entering_weak', false);");
out.println("user_pref('security.warn_entering_weak.show_once', false);");
out.println("user_pref('security.warn_leaving_secure', false);");
out.println("user_pref('security.warn_leaving_secure.show_once', false);");
out.println("user_pref('security.warn_viewing_mixed', false);");
out.println("user_pref('security.warn_viewing_mixed.show_once', false);");
// Disable cache
out.println("user_pref('browser.cache.disk.enable', false);");
out.println("user_pref('browser.cache.memory.enable', true);");
// Disable "do you want to remember this password?"
out.println("user_pref('signon.rememberSignons', false);");
// Disable any of the random self-updating crap
out.println("user_pref('app.update.auto', false);");
out.println("user_pref('app.update.enabled', false);");
out.println("user_pref('extensions.update.enabled', false);");
out.println("user_pref('browser.search.update', false);");
out.println("user_pref('browser.safebrowsing.enabled', false);"); 
//enable javascript 
out.println("user_pref('javascript.enabled', true);"); 
//Optional Tips: User-Agent hijack for http traffic debug
//out.println("user_pref('general.useragent.override', 'Here crack user-agent');");  out.close();

No comments:

Post a Comment