c\#메모리 에서 Selenium chromedriver.exe 방출

배경
Selenium chromedriver.exe 를 실행 하기 위해 c\#코드 를 설 정 했 습 니 다.실행 이 끝 났 을 때 브 라 우 저 close()가 인 스 턴 스 를 닫 습 니 다.(browser=webdriver.Chrome()메모리 에서 chromedriver.exe 를 풀 어야 한다 고 믿 습 니 다.그러나 실행 할 때마다 메모리 에는 chromedriver.exe 인 스 턴 스 가 있 습 니 다.
문제 탐색
이론 적 으로 브 라 우 저.Quit 를 호출 하면 모든 브 라 우 저 옵션 을 닫 고 프로 세 스 를 종료 합 니 다.
하지만 저 는 이 점 을 할 수 없습니다.-여러 테스트 를 병행 하기 때문에 다른 사람의 창 을 닫 기 위해 테스트 를 하고 싶 지 않 습 니 다.따라서,내 테스트 가 실행 되 었 을 때,여전히 많은"chromedriver.exe"프로 세 스 가 실행 되 고 있 습 니 다.
해결 방법

public override void DoJob(IJobExecutionContext context, ILifetimeScope scope, string[] args)
    {
      Console.WriteLine(nameof(LoginReptiles1688Job) + "   -------------------");
      ChromeOptions options = null;
      IWebDriver driver = null;
      try
      {
        options = new ChromeOptions();
        options.AddArguments("--ignore-certificate-errors");
        options.AddArguments("--ignore-ssl-errors");
        var listCookie = CookieHelp.GetCookie();
        if (listCookie != null)
        {
          // options.AddArgument("headless");
        }
        ChromeDriverService service = ChromeDriverService.CreateDefaultService(System.Environment.CurrentDirectory);
        service.HideCommandPromptWindow = true;
        driver = new ChromeDriver(service, options, TimeSpan.FromSeconds(120));
        var setLoginStatus = scope.Resolve<ISetLoginStatus>();
        IReptilesImageSearchService _reptilesImageSearchService = scope.Resolve<IReptilesImageSearchService>();
        CrawlingWeb(_reptilesImageSearchService, driver);
        CrawlingWebShop(_reptilesImageSearchService, driver);
      }
      catch (Exception ex)
      {
        throw ex;
      }
      finally
      {
        driver?.Close(); // Close the chrome window
        driver?.Quit(); // Close the console app that was used to kick off the chrome window
        driver?.Dispose(); // Close the chromedriver.exe

        driver = null;
        options = null;
        detailtry = 0;
        shoptry = 0;
        Console.WriteLine(nameof(LoginReptiles1688Job) + "   -------------------");
      }
    }
C#1 콘 솔 프로그램 에 chrome 드라이버 를 사 용 했 습 니 다.모든 세 가지 방법 을 함께 호출 해 야 지연 프로 세 스 를 청소 할 수 있 습 니 다.
이상 은 c\#메모리 에서 Selenium chromedriver.exe 를 방출 하 는 상세 한 내용 입 니 다.c\#메모리 에서 Selenium 을 방출 하 는 자 료 는 다른 관련 글 을 주목 하 십시오!

좋은 웹페이지 즐겨찾기