Skip to main content

Posts

Showing posts with the label DisableImages

Disabling images - Selenium

One of the ways to increase the speed and performance of your Selenium test is to execute in the headless mode. Also, as we know that disabling images helps to speed up the page load times which make execution faster- so sometimes during run (though NOT recommended for regular test run OR in the case where you flow requires interaction with images like clicking on the button which is an image), if we are not bothered too much whether images are loading on the page and want our execution to be faster- we can disable the images. public static void disableChromeImages(ChromeOptions options) { HashMap images = new HashMap(); images.put("images", 2); // 0-default, 1-Allow, 2-Block HashMap prefs = new HashMap(); prefs.put("profile.default_content_setting_values", images); options.setExperimentalOption("prefs", prefs); } public static void disableFireFoxImages(FirefoxOptions options) { FirefoxProfile profile = new FirefoxProfile(); profi...