Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EdgeDriver throw exception when it's under SYSTEM account #100

Closed
jackchan0833 opened this issue Aug 1, 2023 · 3 comments
Closed

EdgeDriver throw exception when it's under SYSTEM account #100

jackchan0833 opened this issue Aug 1, 2023 · 3 comments
Labels
feedback Feedback, discussion, or question about EdgeDriver

Comments

@jackchan0833
Copy link

We have a auto test project, it's WorkerRole project type, that will deploy into Azure to auto execute. We found it didn't work for EdgeDriver, but work fine for ChromeDriver. We saw the “msedgedriver.exe" progress is under SYSTEM account in Task Manager list, and didn't quit by calling driver.Quit() method.
So we create a sample console application to test it from a Task Scheduler to run with different account. We saw it's working fine under both "Network Service" and "Local Service" account, but not working for "SYSTEM" account. It give "DevToolsActivePort file doesn't exist" error. Looks like EdgeDriver don't support "SYSTEM" account, or we miss any configuration to support this account. Please give some suggestion. Because we require to run it under SYSTEM account due to Azure WorkerRole looks like only support the SYSTEM account.

We use Selenium.WebDriver package 4.11.0, and edge browser version is 115.0.1901.183.

For Task Schedule test, we create a task to run a powershell script, in powershell script to execute the console application and get the test log. The task can be configured with different account. The Powershell script as below:

Write-Host "it's a test" > D:\Test\test.log
& D:\Test\debug\EdgeDriverSample.exe > D:\Test\test.log
Exit

Console applicaiton source code:

class Program
    {
        static void Main(string[] args)
        {
            WebDriver driver = null;
            try
            {
                driver = new EdgeDriver();
                driver.Url = "https://bing.com";

                var element = driver.FindElement(By.Id("sb_form_q"));
                element.SendKeys("WebDriver");
                element.Submit();

                Console.WriteLine("EdgeDriver element submitted.");
                Thread.Sleep(5000);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                driver.Quit();
            }
            finally
            {
                driver.Quit();
            }
        }
    }

The exception as below:
OpenQA.Selenium.WebDriverException: unknown error: Microsoft Edge failed to start: crashed.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from msedge location C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe is no longer running, so msedgedriver is assuming that msedge has crashed.)
at OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse, String commandToExecute)
at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.WebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.WebDriver..ctor(ICommandExecutor executor, ICapabilities capabilities)
at OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeDriverService service, EdgeOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeDriverService service, EdgeOptions options)
at OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeOptions options)
at OpenQA.Selenium.Edge.EdgeDriver..ctor()
at EdgeDriverSample.Program.Main(String[] args) in D:\projects\EdgeDriverSample\EdgeDriverSample\Program.cs:line 19

@jackchan0833 jackchan0833 added the feedback Feedback, discussion, or question about EdgeDriver label Aug 1, 2023
@jbakeri4
Copy link

jbakeri4 commented Aug 1, 2023

I ran into this problem as well, using Java. I created an Edge profile with bare-bones customisations and no installed extensions, copied it from C:\Users\<USER>\AppData\Local\Microsoft\Edge\User Data to <project>\src\main\resources\Edge\ then pointed EdgeOptions to it. Here's my implementation, let me know if it helps:

EdgeOptions options = new EdgeOptions();
            // Verbose logging
            options.setExperimentalOption("excludeSwitches", new String [] {"enable-logging"});
            // Hide the "Personalise your Web experience" prompt by loading Edge with a custom profile
            options.addArguments("profile-directory=Profile 1");
            options.addArguments("user-data-dir=" + System.getProperty("user.dir") + "/src/main/resources/Edge");
            // Disable browser extensions
            options.addArguments("--disable-extensions");
            // Disable any app pop-ups
            options.addArguments("suppress-message-center-popups");
// Optionally run the browser headless
    switch(_interface.toLowerCase())
  {
      case "gui": 
	      {
		      driver = new EdgeDriver(options);								
	      }
	      break;
      case "headless":
	      {
		      options.addArguments("--headless");
		      driver = new EdgeDriver(options);
	      }
  }

@jackchan0833
Copy link
Author

@jbakeri4 We test a Console application to run Edge test, not a Java web applciation to test. If you test it base on "SYSTEM" account, will have this exception.
We have downgrade to "Network Service" account previlege, now it's working. Looks like EdgeDriver don't support for SYSTEM account.

@bwalderman
Copy link
Member

Hi @jackchan0833. It looks like you found the solution. You are correct that Edge doesn't support running as the SYSTEM account for security reasons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback Feedback, discussion, or question about EdgeDriver
Projects
None yet
Development

No branches or pull requests

3 participants