3

크롬에서 웹 사이트 작성을 자동화하기 위해 셀렌을 사용하고 있습니다. exe 또는 XML 파일을 다운로드 할 때 '이 파일 유형은 컴퓨터를 손상시킬 수 있습니다.'라는 팝업과 함께 보관 및 폐기 옵션이 표시됩니다. 이 방법을 프로그래밍 방식으로 해제 하시겠습니까? 나는 내가 시도, C#에서셀렌을 사용하는 크롬 자동 완성에서 '이 파일 유형은 컴퓨터에 해를 끼칠 수 있습니다.'

chromeOptions.AddUserProfilePreference("disable-popup-blocking", "true") 

이것을 구현하고 그러나 이것은 나를 위해 작동하지 않습니다. 이 팝업을 비활성화하는 방법은 무엇입니까? 경고를 수락하는 방법이 없으면? 도와주세요.

+0

은 아마 당신이 필요하다'chromeOptions.AddUserProfilePreference ("해제 - 팝업 차단", " false ")'를 사용하여 팝업 창을 차단합니다. – nullpointer

답변

4

메시지를 사용하지 않으려면 safebrowsing.enabledtrue으로 설정해야합니다. 여기 CSHARP있는 작업 예는 다음과 같습니다

var options = new ChromeOptions(); 
options.AddUserProfilePreference("download.default_directory", "C:\\Downloads"); 
options.AddUserProfilePreference("download.prompt_for_download", false); 
options.AddUserProfilePreference("download.directory_upgrade", true); 
options.AddUserProfilePreference("safebrowsing.enabled", true); 

var driver = new ChromeDriver(options); 
driver.Navigate().GoToUrl("http://www.7-zip.org/a/7z1602.exe"); 

그리고 환경 설정에 대한 설명은

:

https://chromium.googlesource.com/chromium/src/+/master/chrome/common/pref_names.cc

+0

* .mhtml 파일에서 작동하지 않습니다. –

1

은 아마 당신이 필요 팝업 창을 방지하기

대신
chromeOptions.AddUserProfilePreference("disable-popup-blocking", "false") // enables blocking the popup 

로 변경

chromeOptions.AddUserProfilePreference("disable-popup-blocking", "true")  // disables blocking the popup 

입니다.

편집 : 당신이 유해한 파일 내용에 갇히지하는 경우, 당신이 시도하고 사용 실험 크롬 옵션을을 설정할 수 있습니다

Map<String, Object> prefs = new HashMap<String, Object>(); 
prefs.put("safebrowsing.enabled", "true"); 
chromeOptions.setExperimentalOption("prefs", prefs); 

의 DoC here에서 샘플을 인용 :

는 크롬 환경

을 설정 0
ChromeOptions options = new ChromeOptions(); 
Map<String, Object> prefs = new HashMap<String, Object>(); 
prefs.put("profile.default_content_settings.popups", 0); 
options.setExperimentalOption("prefs", prefs); 

날짜 - 2016년 6월 4일 [C#을]

몇 링크를 통해 갔다 및 .Net 여전히 ChromeOptions로를 따라 setExperimentalOption 기본 설정을하지 않는이 알아낼 수 있습니다. 그래서, 플래그 Add Argument to the ChromeOptions using C#로가는 길 중 하나는 here가 될 것이다 나열 :

chromeOptions.AddArgument("--safebrowsing-disable-download-protection"); 

확실히 내용이 악의없는 있도록 내용의 해시 다운로드 URL 및 다운로드를 확인 세이프 브라우징 기능을 사용하지 않습니다.

날짜 - 2016년 6월 4일 [JAVA]

로 인용 here 문서 :

공공 무효 setExperimentalOption (java.lang.String의 이름, 자바 .lang.Object 값)

실험 설정 imental 옵션. 새로운 ChromeDriver 옵션 인 에 아직 유용하지 않음 은 ChromeOptions API을 통해 공개되었습니다.

+1

두 살짜리 네거티브입니다. :) –

+0

@nullpointer가 작동하지 않습니다. –

+0

@kyle_engineer 나는 그 오래된 섬을 안다. 그러나 제안 된 해결책 중 어느 것도 작동하지 않는다. 내 질문에 대답 할 수 있니? –

관련 문제