Friday, 24 May 2019

stop loading images for Functionality testing. - For quick test execution

For Automation scrips to run faster, we can completely avoid loading images on to browser - which internally saves lot of time for execution.

Do you wanted to check how? 

here you go.




For Chrome Browser:

Step 1:
Map<String,Object> images = new HashMap<String,Object>();
images.put("images",2);

Step 2:
Map<String,Object> prefs = new HashMap<String,Object>();
prefs.put("profile.default_content_settings_values",images);

Step 3:
ChromeOptions options = new ChromeOptions()
options.setExperimentalOption("prefs",prefs);

Step 4:
WebDriver driver = new ChromeDriver(options);


For FireFox Browser:

Step 1:
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("permissions.default.image",2);

Step 2:
FirefoxOptions options = new FirefoxOptions();
options.setProfile(profile);
options.setCapability(FirefoxDriver.PROFILE,profile);

Step 3:
WebDriver driver = new FirefoxDriver(options);

No comments:

Post a Comment