目前我正在用HtmlUnit执行selenium脚本。如何设置测试脚本执行时下载的zip文件的下载位置。HtmlUnit设置下载位置
回答
您可以使用Chrome的驱动程序在无头mode.you只需要如下添加选项无头: -
chromeOptions.addArguments("--headless");
Java中的完整的代码将出现如下: -
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);
希望它会帮助你:)
我曾经在Linux机器上运行脚本将chrome驱动程序工作在远程机器上 – Eliyas
当然你也可以在远程运行和使用chrome驱动程序。只是你的远程机器应该有chrome驱动程序二进制文件到位..您可以根据您的操作系统从以下位置下载Chrome二进制文件: - https://chromedriver.storage.googleapis.com/index.html?path=2.32/ –
请参阅: - http://www.qatestingtools.com/论坛话题/ Selenium_Chrome-Driver_Remote-的webdriver –
- 1. nginx设置位置错误下载
- 2. Windows Update API c#:设置下载位置
- 3. Java:如何设置htmlunit
- 4. 下载MAPI33.dll的位置?
- 5. xap文件下载位置
- 6. 设置位置
- 7. 设置下载路径
- 8. 无法在eclipse中设置HTMLUNIT
- 9. 如何在Eclipse项目中设置HtmlUnit?
- 10. 设置tfoot位置
- 11. NSTableViewCell.ImageView设置位置?
- 12. SSRS动态设置表位置/位置
- 13. 正在寻找XSDClassGen的下载位置
- 14. ews托管api下载位置?
- 15. IOS下载文件的位置
- 16. Facebook的缓慢下载位置图片
- 17. 如何更改Gradle下载位置
- 18. 选择文件下载位置
- 19. 下载用户地理位置twitter
- 20. 下载位置Selenium-webdriver Cucumber Chrome
- 21. qt sdk的替代下载位置
- 22. 在Django中指定下载位置
- 23. wget选择位置ftp下载
- 24. 下载WPF应用程序的位置
- 25. Chrome驱动程序硒下载位置
- 26. 如何设置Image控件的占位符(下载时)?
- 27. 如何将PHP设置为从其他位置下载的“管道”?
- 28. 设置默认位置下载到使用flex中的文件类
- 29. 设置滚动位置
- 30. 设置鼠标位置
请参阅:[我如何做X?](https://meta.stackoverflow.com/questions/253069/whats-the-appropriate-new-current-close-reason-for-how-do- i-do-x)对SO的期望是,用户提出一个问题不仅仅是研究来回答他们自己的问题,而是分享研究,代码尝试和结果。这表明你已经花时间去尝试帮助自己,它使我们避免重申明显的答案,最重要的是它可以帮助你得到更具体和相关的答案!另请参见:[问] – JeffC