使用 Java 的 Selenium WebDriver (Selenium 2) 中 selenium.refresh() 的等效代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12212943/
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
Equivalent code of selenium.refresh() in Selenium WebDriver (Selenium 2) using Java
提问by Nazifa Chowdhury
In Selenium RC, I used the following code using Java for refresh on the browser:
在 Selenium RC 中,我使用以下代码使用 Java 在浏览器上刷新:
selenium.refresh();
What is the equivalent code for refresh in WebDriver?
WebDriver 中刷新的等效代码是什么?
回答by Ripon Al Wasim
The following is the equivalent code in Selenium WebDriver using Java:
以下是使用 Java 的 Selenium WebDriver 中的等效代码:
driver.navigate().refresh();
回答by Ripon Al Wasim
Another way to refresh by using Ctrl+F5: to use the WebDriver and Actions instance as below:
另一种使用 Ctrl+F5 刷新的方法:使用 WebDriver 和 Actions 实例,如下所示:
Actions actionObject = new Actions(driver);
actionObject.keyDown(Keys.CONTROL).sendKeys(Keys.F5).perform();
回答by Varun
You can use:
您可以使用:
driver.navigate().refresh();
Look here for example - How To Refresh Current Web Page.
在这里查看示例 -如何刷新当前网页。