如何处理Safari WebseleniumWebdriver的文件下载

如何处理Safari WebseleniumWebdriver的文件下载,第1张

如何处理Safari WebseleniumWebdriver的文件下载

您可以检查以下链接。

dataDir
你工作吗,但不确定

http://pre.google.com/p/selenium/wiki/DesiredCapabilities#Safari_specific

试试这个

Selenium sel = new DefaultSelenium("localhost", 4444, "*safari", baseURL);CommandExecutor executor = new SeleneseCommandExecutor(sel);DesiredCapabilities dc = new DesiredCapabilities();dc.setCapability("safari.options.dataDir", "your folder path");WebDriver browser = new RemoteWebDriver(executor, dc);

新更新:关闭保存下载警告

WebElement link = driver.findElement(By.xpath("myxpath"));clickAndSaveFileIE(link);public static void clickAndSaveFileIE(WebElement element) throws InterruptedException{    try { Robot robot = new Robot();  //get the focus on the element..don't use click since it stalls the driverelement.sendKeys(""); //simulate pressing enter  robot.keyPress(KeyEvent.VK_ENTER); robot.keyRelease(KeyEvent.VK_ENTER); //wait for the modal dialog to open  Thread.sleep(2000); //press s key to save  robot.keyPress(KeyEvent.VK_S); robot.keyRelease(KeyEvent.VK_S); Thread.sleep(2000); //press enter to save the file with default name and in default location robot.keyPress(KeyEvent.VK_ENTER); robot.keyRelease(KeyEvent.VK_ENTER);        } catch (AWTException e) { e.printStackTrace();        }


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5642008.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存