2017-04-06 1 views
0

ChromeDriver 2.29로 업그레이드하면 '자동 다운로드'localhost : 9000 '의 기본값이'묻기 '로 설정됩니다. 내 테스트가 다운로드를 호출하는 링크를 클릭 할 때마다 Save As windows 대화 상자가 열립니다. 이전에는 자동으로 Chrome의 기본 다운로드 폴더로 다운로드되었습니다.ChromeDriver 2.29 자동 다운로드를 기본적으로 허용으로 설정할 수 없음

chromeriver (크롬이 아님)에서이 설정의 기본값을 '허용'으로 변경하려면 어떻게해야합니까?

나는 chrome.switches를 사용하여 시도했지만 그들은 작동하지 않았다 :

chrome.switches=--disable-extensions,--disable-infobars,--allow-insecure-localhost,--safebrowsing-disable-download-protection 

크롬의 기본 설정은 모든 사이트에 대해 '허용'한다. 'http://localhost:9000'도 예외 목록에 추가되었습니다.

enter image description here

답변

0

당신이 기능을 사용하여 기본 다운로드 위치를 설정할 수 있습니다. 그것은 해당 폴더에 파일을 다운로드합니다, 어떤 위로의 팝업 포기하지 않을 것

그냥

DesiredCapabilities capabilities = new DesiredCapabilities(); 
String downloadPath = System.getProperty("user.dir")+ "\\Downloads"; 

HashMap<String, Object> chromePrefs = new HashMap<>(); 
chromePrefs.put("download.default_directory", downloadPath); 
chromePrefs.put("profile.default_content_settings.popups", 0); 
chromePrefs.put("safebrowsing.enabled", "true"); 

ChromeOptions options = new ChromeOptions(); 

HashMap<String, Object> chromeOptionsMap = new HashMap<>(); 
options.setExperimentalOption("prefs", chromePrefs); 
options.addArguments("--test-type"); 

capabilities = DesiredCapabilities.chrome(); 
capabilities.setCapability(ChromeOptions.CAPABILITY,chromeOptionsMap); 
capabilities.setCapability(ChromeOptions.CAPABILITY, options); 
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); 

는 당신이 어떤 문제에 직면하는 경우 나

+0

그렇게하지 알게 코드의 아래 라인 시도 DesiredCapabilities/Chrome 옵션을 사용하고 싶습니다. 대신 Chrome Switch 또는 명령 줄 인수로 사용하십시오. –

+0

기능을 사용하는 경우의 차이점 – Karthikeya

+0

테스트 자동화 프레임 워크는 ChromeDriver 호출을 자동으로 처리하는 Serenity BDD 프레임 워크를 사용하여 작성됩니다. 속성 파일이나 명령 줄을 통해 'chrome.switches'를 전달할 수 있습니다. 따라서 DesiredCapabilities 사용과 관련이없는 접근 방법을 요청하고있었습니다. –

관련 문제