使用 Java 在 WebDriver 中通过 Ctrl+F5 刷新浏览器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12299960/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 08:21:51  来源:igfitidea点击:

Browser refresh by Ctrl+F5 in WebDriver using Java

javaselenium-webdriverpage-refreshbrowser-refresh

提问by Ripon Al Wasim

I have refreshed the browser in WebDriver using java as below code:

我已经使用 java 刷新了 WebDriver 中的浏览器,如下代码:

driver.navigate().refresh();

How can I do that by pressing Ctrl+F5 in WebDriver using Java?

如何通过在使用 Java 的 WebDriver 中按 Ctrl+F5 来做到这一点?

回答by Ami

I think you can use the WebDriver and Actions instance as below:

我认为您可以使用 WebDriver 和 Actions 实例,如下所示:

Actions actionObject = new Actions(driver);
actionObject.keyDown(Keys.CONTROL).sendKeys(Keys.F5).keyUp(Keys.CONTROL).perform??();