25 Mayıs 2017 Perşembe

selenium disable devoloper extension

System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-extensions");
driver = new ChromeDriver(options);


ChromeOptions options = new ChromeOptions();
options.addArguments("chrome.switches","--disable-extensions");
System.setProperty("webdriver.chrome.driver",(System.getProperty("user.dir") + "//src//test//resources//chromedriver_new.exe"));
driver = new ChromeDriver(options);



The official way to disable the popup seems to be like this:
  1. Pack your extension and install it via drag-and-dropping the .crx file into the chrome://extensions page.
    (you'll get an "Unsupported extensions disabled" popup if you try restarting Chrome at this stage)
Then for Win7/8:
  1. Download Chrome group policy templates from: http://dl.google.com/dl/edgedl/chrome/policy/policy_templates.zip
  2. Copy [zip]\windows\admx\chrome.admx to c:\windows\policydefinitions
  3. Copy [zip]\windows\admx\[yourlanguage]\chrome.adml to c:\windows\policydefinitions\[yourlanguage]\chrome.adml (not c:\windows\[yourlanguage])
  4. In Chrome, go to Settings > Extensions
  5. Check the Developer Mode checkbox at the top
  6. Scroll down the list of disabled extensions and note the ID(s) of the extensions you want to enable. LogMeIn, for example, is ID: nmgnihglilniboicepgjclfiageofdfj
  7. Click Start > Run, and type gpedit.msc <ENTER>
  8. Expand User Configuration > Administrative Templates > Google Chrome > Extensions
  9. Double-click to open Configure extension installation whitelist policy
  10. Select Enabled, then click Show...
  11. In the list, enter the ID(s) of the extensions you noted in Step 7
  12. Click OK and restart Chrome.
That's it!
I worked around this issue by using AutoIT.
First, you'll need to create the script.
closechromewarning.au3:
WinWaitActive("[CLASS:Chrome_WidgetWin_1]")
Send("{ESC}")
The script needs to be compiled to a .exe, then place the .exe in the path so it can be run.
Function that closes the warning, using c# syntax:
public void CloseChromeDialog()
{
    System.Threading.Thread.Sleep(5000);
    Process.Start(@".\closechromewarning.exe");
}
Sleep(4000) did work, but I upped it to Sleep(5000) just to be sure.
Calling CloseChromeDialog():
if(browser == chrome) //pseudo code
    CloseChromeDialog();