how to disable chrome extension in selenium

前端 未结 3 1189
礼貌的吻别
礼貌的吻别 2020-12-10 07:31

I am trying to disable all chrome extensions when starting up my selenium chrome. But all extensions keep starting up each time I run the code. Is there a way of disabling t

相关标签:
3条回答
  • 2020-12-10 07:45

    Setting capability chrome.switches did not work for me (Chrome Version 53.0.2785.143 m, ChromeDriver 2.18.343845)

    Instead using options works:

    ChromeOptions options = new ChromeOptions();
    options.addArguments("--disable-extensions");
    driver = new ChromeDriver(options);
    

    or as per Chrome Driver documentation to set options as capability

    ChromeOptions options = new ChromeOptions();
    options.addArguments("--disable-extensions");
    caps.setCapability(ChromeOptions.CAPABILITY, options);
    driver = new ChromeDriver(caps);
    

    ChromeDriver(capabilities) is deprecated

    0 讨论(0)
  • 2020-12-10 07:49

    Found a fix.

      capabilities.setCapability("chrome.switches", Arrays.asList("--disable-extensions"));
    
    0 讨论(0)
  • 2020-12-10 07:58

    Use the following to set chrome options:

    ChromeOptions options = new ChromeOptions();
    options.addArguments("chrome.switches","--disable-extensions");
    
    0 讨论(0)
提交回复
热议问题