Here is a solution that will work with the latest version of Chrome 74 .
- Go to
chrome://extensions - Click on the Details button for the desired extension

- Copy URL (contains
id your extension)
Now we have to go to the above URL and then click on the allow in incognito switch.
Java:
driver.get("chrome://extensions/?id=bhghoamapcdpbohphigoooaddinpkbai"); JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("document.querySelector('extensions-manager').shadowRoot.querySelector('#viewManager > extensions-detail-view.active').shadowRoot.querySelector('div#container.page-container > div.page-content > div#options-section extensions-toggle-row#allow-incognito').shadowRoot.querySelector('label#label input').click()");
Python:
driver.get("chrome://extensions/?id=bhghoamapcdpbohphigoooaddinpkbai") driver.execute_script("return document.querySelector('extensions-manager').shadowRoot.querySelector('#viewManager > extensions-detail-view.active').shadowRoot.querySelector('div#container.page-container > div.page-content > div#options-section extensions-toggle-row#allow-incognito').shadowRoot.querySelector('label#label input').click()");
Continue reading if you want to know how and why
Root cause:
As part of the Chrome browser improvements, Google has moved all the Chrome options to shadow dom . Thus, you cannot access the allow in incognito switch element as find_element to the selenium find_element method, which will point to the source domain of the page. Thus, we must switch to shadow dom and access the elements in the shadow tree .
Details:
Shadow DOM: 
Note: we will refer to the terms shown in the picture. Therefore, please follow the picture for a better understanding.
Decision:
To work with the shadow element first , we need to find the shadow host to which the shadow house is attached. Here is an easy way to get the shadow root based on shadowHost.
private static WebElement getShadowRoot(WebDriver driver,WebElement shadowHost) { JavascriptExecutor js = (JavascriptExecutor) driver; return (WebElement) js.executeScript("return arguments[0].shadowRoot", shadowHost); }
And then you can access the shadow tree element using the shadowRoot element.
In order to simplify all of the above steps, the method below has been created.
public static WebElement getShadowElement(WebDriver driver,WebElement shadowHost, String cssOfShadowElement) { WebElement shardowRoot = getShadowRoot(driver, shadowHost); return shardowRoot.findElement(By.cssSelector(cssOfShadowElement)); }
Now you can get the shadowTree element in one method call
WebElement shadowHost = driver.findElement(By.cssSelector("shadowHost_CSS_Goes_here)); WebElement shadowTreeElement = getShadowElement(driver,shadowHost,"shadow_tree_element_css");
And do the operations as usual, for example .click() , .getText() .
shadowTreeElement.click()
It looks simple when you have only one level of shadow DOM. But here, in this case, we have several levels of shadow houses. Therefore, we must access the element by reaching each shadow host and root. 
Below is a code snippet using the methods mentioned above (getShadowElement and getShadowRoot).
// Locate shadowHost on the current dom WebElement shadowHostL1 = driver.findElement(By.cssSelector("extensions-manager")); // now locate the shadowElement by traversing all shadow levels WebElement shadowElementL1 = getShadowElement(driver, shadowHostL1, "#viewManager > extensions-detail-view.active"); WebElement shadowElementL2 = getShadowElement(driver, shadowElementL1,"div#container.page-container > div.page-content > div#options-section extensions-toggle-row#allow-incognito"); WebElement allowToggle = shadowElementL2.findElement(By.cssSelector("label#label input")); allowToggle.click();
You can complete all of the above steps in a single js call, as mentioned at the beginning of the answer (added below only to reduce confusion).
WebElement allowToggle = (WebElement) js.executeScript("return document.querySelector('extensions-manager').shadowRoot.querySelector('#viewManager > extensions-detail-view.active').shadowRoot.querySelector('div#container.page-container > div.page-content > div#options-section extensions-toggle-row#allow-incognito').shadowRoot.querySelector('label#label input')");