c\#메모리 에서 Selenium chromedriver.exe 방출
2576 단어 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 을 방출 하 는 자 료 는 다른 관련 글 을 주목 하 십시오!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
C#Task를 사용하여 비동기식 작업을 수행하는 방법라인이 완성된 후에 이 라인을 다시 시작할 수 없습니다.반대로 조인(Join)만 결합할 수 있습니다 (프로세스가 현재 라인을 막습니다). 임무는 조합할 수 있는 것이다. 연장을 사용하여 그것들을 한데 연결시키는 것이...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.