Configure Selenium EdgeDriver to prevent uri/protocol_handler popups.

I just spend a few hours on this, so here’s a quick public not for anyone trying to do selenium testing on Microsoft Edge Chromium that runs into a popup for custom uri-handlers:

You can disable them by passing the following code-block as experimental options in microsoft edge.

{	"protocol_handler": {
		"allowed_origin_protocol_pairs": {
			"": {
				"myUriHandler": true

Here’s my proof of concept / quick and dirty implementation in java:

		EdgeDriver driver = null;
		EdgeOptions opt=new EdgeOptions();

		String protocolHandlerSetting="	{\"protocol_handler\": {\r\n"
			+ "		\"allowed_origin_protocol_pairs\": {\r\n"
			+ "			\"\": {\r\n"
			+ "				\"myUriHandler\": true\r\n"
			+ "			}\r\n"
			+ "		}\r\n"
			+ "	}}";
		opt.setExperimentalOption("prefs", new Gson().fromJson(protocolHandlerSetting, HashMap.class));
		driver = new EdgeDriver(opt);


Leave a Reply

Your email address will not be published. Required fields are marked *