这是一个 chrome网页驱动的问题,而不是用刷新。如果你没有,你需要下载chrome web驱动,或者你的环境PATH变量可能有问题。
也许这能帮助你。
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using Serilog;
using System.IO;
using System.Reflection;
namespace StackOverFlow.Answer.Selenium.RefreshPage
{
class RefreshPage
{
public static IWebDriver driver;
[Test]
[Category("RefreshPage")]
public void RefreshPageTest()
{
Log.Information("Get instance Chrome Browser");
driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), OptionsChrome());
Log.Information("Acess your url site");
driver.Navigate().GoToUrl("http://YourUrlSite/index.aspx");
Log.Information("Refresh page command");
driver.Navigate().Refresh();
}
private ChromeOptions OptionsChrome()
{
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("--start-maximized");
chromeOptions.AddArguments("--disable-infobars");
chromeOptions.AddArguments("--disable-notifications");
return chromeOptions;
}
}
}