如何使用Chrome Webdriver关闭下载横幅? [英] How to close download banner with Chrome Webdriver?
本文介绍了如何使用Chrome Webdriver关闭下载横幅?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的测试中,我下载了一个文件,它工作正常,但后来当我尝试点击一个元素时,我无法滚动到视图中,页面底部的chrome下载对话框就出现了。没有办法移动我需要点击进入视图的按钮,那么有没有办法用chrome webdriver关闭下载框?
In my tests I download a file, which works fine, but later when I am trying to click on an element I cannot scroll into view, the chrome download dialog box on the bottom of the page is in the way. There is no way to move the button I need to click into view, so is there a way to close that download box with chrome webdriver?
解决方案
您可以使用 org.openqa.selenium.interactions.Actions
类移动到元素视图
:
You can use the org.openqa.selenium.interactions.Actions
class to move to an element view
:
WebElement element = driver.findElement(By.id("my-id"));
Actions actions = new Actions(driver);
actions.moveToElement(element);
// actions.click();
actions.perform();
这篇关于如何使用Chrome Webdriver关闭下载横幅?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文