1

Python code works:

import time
from selenium import  webdriver
from selenium.webdriver.common.action_chains import ActionChains
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-automation'])

But the C# code is not working:

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddAdditionalCapability("excludeSwitches", "disable-popup-blocking");
am9417
  • 994
  • 8
  • 18
mtest
  • 11
  • 1
  • 4

2 Answers2

7
        List<string> ls = new List<string>();
        ls.Add("enable-automation");
        ChromeOptions options = new ChromeOptions();
        options.AddExcludedArguments(ls);
        using (IWebDriver driver = new ChromeDriver("C:\\Program\\chromedriver", options))
        {
            Console.ReadKey();
        }
  • 1
    Could you add some explanation to this out-of-nowhere code ? It will help OP if you explain what he was doing wrong, what your change to make it work, and why. – vincrichaud May 15 '19 at 13:53
0

I use "excludeSwitches" to get rid of the error showing on the output console. A device attached to the system is not functioning error using ChromeDriver Selenium on Windows OS

This is my code:

var options = new ChromeOptions();
List<string> ls = new List<string>();
ls.Add("enable-automation");
ls.Add("excludeSwitches");
ls.Add("enable-logging");
ls.Add("disable-popup-blocking");
options.AddExcludedArguments(ls); //set option element in list to options
IWebDriver driver = new ChromeDriver(options);  //open webdriver with your options
tian
  • 1
  • 1
  • 1