C # Selenium ChromeDriver: Google Chrome does not work on startup as administrator

I encountered a normal situation when using Selenium Web Driver C # with Chrome: if the process running the tests starts as an administrator (Visual Studio or nunit3-console.exe), Chrome will not be able to download.

Context

  • OS: Windows 7 x64
  • Chrome: version 64.0.3282.167 (official build) (64-bit)
  • Selenium.Chrome.WebDriver (chromedriver.exe): 2.35.0
  • Local policy does not allow chrome extensions

Steps

  • Run a test that also initializes the driver

    var options = new ChromeOptions();
    
    //TODO: check if really needed
    options.AddAdditionalCapability("useAutomationExtension", false);
    options.AddArguments("--allow-no-sandbox-job");
    options.AddArguments("--ignore-certificate-errors");
    
    var driver = new ChromeDriver(options);
    
  • ChromeDriver starts successfully:

    Starting ChromeDriver 2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73) on
    port 61771
    Only local connections are allowed.
    
    DevTools listening on ws://127.0.0.1:12890/devtools/browser/e50864bd-9c30-445c-a3f8-e33d6b6e5b49
    
  • Chrome opens but tab doesn't load

chrome failed tab

  1. If I update the tab when connecting, I get the following exception information:

" System.InvalidOperationException" WebDriver.dll,

: ,

( : chrome = 64.0.3282.167)

( : chromedriver = 2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73), = Windows NT 6.1.7601 SP1 x86_64) (InsecureCertificate)

, . , , , .

: # Selenium ChromeDriver + Chrome . ?


, :

static void Main(string[] args)
{
    var options = new ChromeOptions();
    // this is required since otherwise it will try to load some extension which is not allowed by local policy
    options.AddAdditionalCapability("useAutomationExtension", false);
    // try to catch some errors, but does not seem to work
    options.AddArguments("--enable-logging");
    options.AddArguments("--v=1");
    var driver = new ChromeDriver(options);
    driver.Navigate().GoToUrl("http://localhost");
}

- , , Chrome Driver ( 2.35, 2.36). (Windows 7 Windows 10 ) ( Chrome).


Tarun Lalwani , , , + + Chrome:

  • - , Chrome admin:

    • : dir="C:\Users\<my-dos-profile-name>\AppData\Local\Temp\scoped_dir21000_25907" ( )
    • : dir="C:\WINDOWS\TEMP\scoped_dir7236_26307"
  • chrome.debug Chrome ( , ). :

[0303/120050.213: : process_reader_win.cc(151)] SuspendThread: . (0x5)
[0303/120050.214: : process_reader_win.cc(123)] NtOpenThread: { } , . (0xc0000022)
[0303/120050.215: : exception_snapshot_win.cc(88)] thread ID 13672
[0303/120050,215: : crash_report_exception_handler.cc(62)] ProcessSnapshotWin::

  1. Chrome admin, . (cmd) :

C:\Program Files (X86)\Google\Chrome\Application > [7244: 16744: 0303/125934,383: : gpu_process_transport_factory.cc(1009)] .
[7244: 13716: 0303/125956,057: : connection_factory_impl.cc(381)] MCS -118

, , , Chrome Chrome.

+4
1

--no-sandbox. , no-sandbox .

:

var options = new ChromeOptions();
options.SetLoggingPreference(LogType.Driver, LogLevel.All);
options.AddAdditionalCapability("useAutomationExtension", false);
options.AddArguments("--no-sandbox");
var driver = new ChromeDriver(options);
driver.Navigate().GoToUrl("http://localhost");

SetLoggingPreference , no-sandbox. Chrome :

[17532: 18272: 0301/225923,296: : gpu_process_transport_factory.cc(1009)] .


: chromedriver.exe , RemoteWebDriver ChromeDriver ( Tarun Lalwani ):

var options = new ChromeOptions();
options.SetLoggingPreference(LogType.Driver, LogLevel.All);
options.AddAdditionalCapability("useAutomationExtension", false);
var driver = new RemoteWebDriver(new Uri("http://localhost:9515"), options);
driver.Navigate().GoToUrl("http://localhost");
+3

Source: https://habr.com/ru/post/1693700/


All Articles