![](/img/trans.png)
[英]How do I set a proxy for firefox using Selenium webdriver with Java?
[英]How do I accept the download prompt on the firefox webdriver using selenium in JAVA?
我正在测试正在构建的页面,希望能找到是否可以使用硒接受下载提示? 我正在使用Firefox Webdriver。
您可以尝试使用以下代码来下载zip文件:
FirefoxProfile profile = new FirefoxProfile();
//MIME type for zip file "application/zip"
profile.setPreference("browser,helperapps.neverAsk.SaveToDisk", "application/zip");
// 0 = desktop, 1 = default download folder , 2 = user defined location.
profile.setPreference("browser.download.folderList",0);
driver = new FirefoxDriver(profile);
baseUrl = " http://www.yourwebsite.com ";
driver.get(baseUrl);
driver.findElement(By.id("downloadFile")).click;
您为什么不选择Sikuli,这太简单了。
在构建路径中添加sikuli-java.jar文件,安装Picpick soft,使用Picpick保存保存文件的图像,单击确定按钮。
输入以下命令
new Screen().click(new Pattern("E:\\simage\\save.png")); //here e:\\..is image file path
new Screen().click(new Pattern("E:\\simage\\ok.png"));
结束了。
是的,sikuli是一个简单的解决方案,您可以使用它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.