1
final DesiredCapabilities capabilities = DesiredCapabilities.chrome();
final ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--start-maximized");
Map<String, Object> prefs = new LinkedHashMap<>();
prefs.put("profile.default_content_setting_values.images", 2);
chromeOptions.setExperimentalOption("prefs", prefs);
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

WebDriver driver = new ChromeDriver(capabilities);

driver.get("https://www.example.com/");

This code will stop the image loading. Now I want to re-enable the Image loading again with the same driver object ??

    prefs.put("profile.default_content_setting_values.images", 0);
    chromeOptions.setExperimentalOption("prefs", prefs);
    capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

    driver = new ChromeDriver(capabilities);
    driver.get("https://connect.secure.wellsfargo.com/auth/login/present?origin=yodlee");

I am using this above code to changing the pref again to start loading the images again but with this code, new chrome is opening

driver = new ChromeDriver(capabilities)

but I want this with the same chrome driver.

My simple ask is to enable/disable image loading with the same driver object ?

  • it will be great if some body help me on this
Abhay Gupta
  • 119
  • 2
  • 10
  • Possible duplicate of [How can I reconnect to the browser opened by webdriver with selenium?](https://stackoverflow.com/questions/47861813/how-can-i-reconnect-to-the-browser-opened-by-webdriver-with-selenium) – undetected Selenium May 10 '18 at 10:01
  • What you can do in this scenario is to create 2 profile then load them one by one , because you are using new ChromeDriver(capabilities) ,which would initialize the browser instance. – cruisepandey May 10 '18 at 11:04

0 Answers0