2017-09-05 6 views
-1

현재 HtmlUnit을 사용하여 셀렌 스크립트를 실행 중입니다. 테스트 스크립트 실행시 다운로드 한 Zip 파일의 다운로드 위치를 어떻게 설정할 수 있습니까?HtmlUnit 다운로드 위치 설정

chromeOptions.addArguments("--headless"); 

자바의 전체 코드는 다음과 같이 나타납니다 : - -이 :

+0

참조 : [어떻게해야합니까?] (https://meta.stackoverflow.com/questions/253069/whats-the-new-current-close-reason-for-how-do- i-do-x) SO에 대한 기대는 사용자가 질문을하는 것이 연구가 자신의 질문에 대답 할뿐만 아니라 연구, 코드 시도 및 결과를 공유한다는 것입니다. 이것은 시간을내어 자신을 도우려는 것을 보여 주며, 명백한 답을 되풀이하지 않아도되며, 무엇보다도보다 구체적이고 관련성있는 답변을 얻는 데 도움이됩니다! 참고 : [ask] – JeffC

답변

0

당신은 mode.you 바로 아래 헤드리스 (headless) 등의 옵션을 추가 할 필요가 헤드리스에 크롬 드라이버를 사용할 수 있습니다

System.setProperty("webdriver.chrome.driver","D:\\Workspace\\JmeterWebdriverProject\\src\\lib\\chromedriver.exe"); 
ChromeOptions chromeOptions = new ChromeOptions(); 
chromeOptions.addArguments("--headless"); 
chromeOptions.addArguments("--start-maximized"); 
WebDriver driver = new ChromeDriver(chromeOptions); 
driver.get("https://google.com"); 

아래 코드에 의해 특정 경로에서 다운로드를 설정하는 chromedriver을 사용할 수 있습니다 : -

String downloadFilepath = "/path/to/download"; 
HashMap<String, Object> chromePrefs = new HashMap<String, Object>(); 
chromePrefs.put("profile.default_content_settings.popups", 0); 
chromePrefs.put("download.default_directory", downloadFilepath); 
ChromeOptions options = new ChromeOptions(); 
options.setExperimentalOption("prefs", chromePrefs); 
DesiredCapabilities cap = DesiredCapabilities.chrome(); 
cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); 
cap.setCapability(ChromeOptions.CAPABILITY, options); 
WebDriver driver = new ChromeDriver(cap); 

그것은 당신을 도울 것입니다 희망 :)

+0

리눅스 컴퓨터에서 스크립트를 실행하는 데 사용됩니다. 원격 컴퓨터에서 크롬 드라이버 작업을 수행합니다. – Eliyas

+0

물론 원격에서도 크롬 드라이버를 실행하고 사용할 수 있습니다. 원격 컴퓨터에는 크롬 드라이버 바이너리가 있어야합니다. .. 아래 위치에서 OS별로 Chrome 이진 파일을 다운로드 할 수 있습니다. - https://chromedriver.storage.googleapis.com/index.html?path=2.32/ –

+0

다음을 참조하십시오. - http://www.qatestingtools.com/ forum-topic/Selenium_Chrome-Driver_Remote-Webdriver –