0

Well, I'm trying to disable this popup, because a NoSuchElementException occurs because this is interfering on the UI.

...

private static ChromeDriver CreateDriver()
        {
            var chromeOptions = new ChromeOptions();
            //{
            //    BinaryLocation = Path.Combine(Environment.CurrentDirectory, "chromedriver/chromedriver"),
            //};

            /*
             // ONLY FOR TESTING IN WINDOWS
            chromeOptions.AddArguments("headless");
            chromeOptions.AddArgument("--start-maximized");
            //chromeOptions.AddArgument("window-size=932,1025");
            chromeOptions.AddArgument("--disable-infobars");
            chromeOptions.AddArgument("--disable-dev-shm-usage");
            chromeOptions.AddArgument("--no-sandbox");
            chromeOptions.AddArgument("--remote-debugging-port=9222");
            */

            chromeOptions.AddArgument("--no-sandbox");
            chromeOptions.AddArgument("--disable-infobars");
            chromeOptions.AddArgument("--disable-extensions-file-access-check");
            chromeOptions.AddArgument("--disable-extensions");

            chromeOptions.AddArguments("--lang=en");

            // --disable-extensions-file-access-check

            //chromeOptions.AddAdditionalOption("useAutomationExtension", false);

            chromeOptions.AddExcludedArgument("enable-automation");

            chromeOptions.AddArgument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36");

            if (IsLinux)
            {
                // Thanks to: https://stackoverflow.com/questions/41133391/which-chromedriver-version-is-compatible-with-which-chrome-browser-version
                // https://chromium.woolyss.com/

                var service = ChromeDriverService.CreateDefaultService();

                service.LogPath = Path.Combine(Environment.CurrentDirectory, "logs", "client.log");
                service.EnableVerboseLogging = true;

                chromeOptions.AddArguments("headless");
                chromeOptions.AddArgument("--start-maximized");

                //chromeOptions.AddArguments("--headless");
                //chromeOptions.AddArguments("--disable-gpu");
                //chromeOptions.AddArguments("--window-size=1280,800");
                //chromeOptions.AddArguments("--allow-insecure-localhost");

                //chromeOptions.AddArgument("--disable-infobars");
                //chromeOptions.AddArgument("--disable-dev-shm-usage");
                //chromeOptions.AddArgument("--no-sandbox");
                //chromeOptions.AddArgument("--remote-debugging-port=9222");

                return new ChromeDriver(service, chromeOptions);
            }

            return new ChromeDriver(chromeOptions);
        }

This options is what I tried, but the popup is still showing.

        chromeOptions.AddArgument("--disable-infobars");
        chromeOptions.AddArgument("--disable-extensions-file-access-check");
        chromeOptions.AddArgument("--disable-extensions");

In Java I saw this option also: System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");

But obviously I don't have any change to reimplement this on C#. So I don't know where can I continue.

This popup shows only when the chromeOptions.AddArgument("--no-sandbox"); option is exposed (this is obligatory in Linux). So I don't know what do exactly.

Any help here would be wonderful!

Note: I'm using ChromeDriver 79.0.3945.36

z3nth10n
  • 2,341
  • 2
  • 25
  • 49
  • I posted this question because this question didn't resolved anything. I think it's not neccesary to close any question, because any of the solutions I tried has worked. – z3nth10n Mar 03 '20 at 13:55
  • It might sound goofy, but try removing the double dashes from the argument names. For instance use `AddArgument("disable-extensions")` instead. – Greg Burghardt Mar 03 '20 at 13:57
  • Thanks @GregBurghardt for you quick answer! But I tried this also without luck. :( – z3nth10n Mar 03 '20 at 13:58
  • Ok, now it's working, but right now password field is also interfering with the UI. Thanks. This is my code: https://pastebin.com/pm7nJE4a – z3nth10n Mar 03 '20 at 14:07
  • Try this, short answer, worked for me options.AddExcludedArgument("enable-automation"); – Vu Nguyen Apr 14 '21 at 04:49

0 Answers0