A recent Edge update has caused a large number of our Selenium-powered integration tests to fail due to the JSON Viewer, which apparently is now enabled by default. It no longer renders the file content in a simple <pre>
but adds a ton of nested <div>
s.
Disabling the JSON Viewer would restore functionality, and I suppose it may be possible to do so via the EdgeOptions
. However, I have not been able to find out how the option for the JSON Viewer is called.
My config:
EdgeOptions options = new EdgeOptions();
Map<String, Object> prefs = new HashMap<>();
prefs.put("download.default_directory", TMP_DIRECTORY.toString());
prefs.put("download.directory_upgrade", true);
// prefs.put(<enable json viewer>, false); <-- what I would like to add
options
.setExperimentalOption("prefs", prefs)
...
EDIT: Solved per Xudong Peng's reply as follows:
EdgeOptions options = new EdgeOptions();
Map<String, Object> prefs = new HashMap<>();
prefs.put("download.default_directory", TMP_DIRECTORY.toString());
prefs.put("download.directory_upgrade", true);
List<String> arguments = new ArrayList<>();
arguments.add("--disable-features=msEdgeJSONViewer");
options
.setExperimentalOption("prefs", prefs)
.addArguments(arguments)
...
If you want to disable the JSON Viewer in Microsoft Edge with Selenium, just add argument in EdgeOptions
, something like this:
options.AddArgument("--disable-features=msEdgeJSONViewer");