Chrome command line options for windowed HTML applications

An example of combination of chrome command line arguments to launch an HTML page…

  • windowed, that means in “app mode” (no toolbars, –app=”<url>” argument),
  • with no web security checks (= allowed DOM manipulation of frame loaded on a different domain, –-disable-web-security), that allows Javascript to modify the content of forms loaded in other frames from external URLs, for full-flegded interactions.
  • with a custom user-agent (–user-agent). I personally use it for a website that – with a mobile User-Agent – displays much less annoying banners and a layout that better fits its small frame;
  • with independent user session settings (–user-data-dir=”C:/path-to-temp-files”). That’s necessary to avoid chrome sharing settings with your current chrome user session, and mandatory to enable ad-hoc settings like the web security

Firefox user preferences with selenium (behat+mink) to bypass a proxy or disable cache

At work we are testing an existing application with behat+mink. We normally use goutte driver, but in some cases (when javascript is needed) we need to use selenium server piloting firefox.

When using firefox, the page is loaded including external javascript (google analytics, network ads etc..) so it needs connetivity. An alternative is disabling external requests on the testing environment or use a fake DNS entry, but that wasn’t a viable solution for us.

A small problem I had was bypassing the office network proxy, that requires a proxy auto config file (PAC) when firefox was running. You can find many links online mentioning the various firefox preferences you can set, for example network.proxy.http and network.proxy.http_port to specify a proxy, or network.http.use-cache to enable/disable the browser cache.

In my configuration (ubuntu 12.04, with selenium 2.28, firefox 18.0.1), the preferences file read by firefox is located at /usr/lib/firefox/defaults/pref/proxy.js, where you can add the various calls to user_pref([settings], [value]) .

Here an example of how I changed the puppet manifest of the box to make things working for us

file { "/usr/lib/firefox/defaults/pref/proxy.js":
 content =>
'user_pref("network.proxy.autoconfig_url", "http://chante-with-your-value/default.pac");
user_pref("network.http.use-cache", false);
user_pref("network.dnsCacheExpiration", 1);
user_pref("network.proxy.type", 2);'
}