0

I want to disable the "Disable Developer Mode Extensions" popup while keeping an extension as mentioned in this post keep "Disable developer mode" closed while adding extension

There was no answer and I'm trying to do the same thing. Is there a chrome option like this available for Selenium?

Justin
  • 1
  • 5

3 Answers3

1
import pywinauto
window_title = "Disable Developer Mode Extensions"
app = pywinauto.Application().connect(name_re=window_title)
win_ext = app.window(name=window_title)
win_ext.close()
0

Here is the Answer to your Question:

While working with Selenium 3.4.0, chromedriver v2.30, Google Chrome 59.0 through Java bindings, you can use the ChromeOption class to disable the "Disable Developer Mode Extensions" popup as follows:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class Q44959944_dev_extn {

    public static void main(String[] args) {


        System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
        ChromeOptions options = new ChromeOptions();
        options.addArguments("start-maximized");
        options.addArguments("disable-infobars");
        options.addArguments("--disable-extensions"); 
        WebDriver driver = new ChromeDriver(options);
        driver.navigate().to("https://google.com");
    }
}

Let me know if this Answers your Question.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

The solution provided by DebanjanB doesn't work with the latest version of Chrome and Chrome Driver.

To get this to work you need to specify the exclude switches and useAutomationExtension in the prefs flag.

                System.setProperty("webdriver.chrome.driver", Constant.BROWSER_CHROME_PATH);

                Map prefs = new HashMap<String, Object>();
                prefs.put("profile.default_content_setting_values.geolocation", 1); // 1:allow 2:block
                prefs.put("useAutomationExtension", false);
                prefs.put("excludeSwitches", Collections.singletonList("enable-automation"));

                ChromeOptions chromeOptions = new ChromeOptions();
                chromeOptions.addArguments("-incognito");
                chromeOptions.addArguments("--disable-gpu"); // applicable to windows os only
                chromeOptions.setExperimentalOption("prefs", prefs);
                chromeOptions.addArguments("--no-sandbox");

                wDriver = new ChromeDriver(chromeOptions);
                ((LocationContext)wDriver).setLocation(new Location(37.774929, -122.419416, 0));

                wDrivers.put("chrome", wDriver);
                log.info("New Chrome Browser Instance Created.");
CoffeeTime
  • 305
  • 1
  • 6
  • 17