SeleniumWebDriver FluentAutomation Chrome隐姓埋名



我们正在使用FluentAutomation.SeleniumWebDriver来驱动我们的集成测试。我们将其配置为

public IntegrationTest()
{
    SeleniumWebDriver.Bootstrap(SeleniumWebDriver.Browser.Chrome);
}

我的问题是如何告诉它以匿名模式运行?我遇到的问题是,测试有时会使用我在本地使用的cookie,这可能会影响测试。

我不知道如何始终强制它在匿名模式下运行,但您可以始终在匿名模式中打开一个新窗口并使用它,这可能会有所帮助。

_driver.FindElement(By.TagName("body").SendKeys(Keys.Control + Keys.Shift + "n");

您可以在以下窗口之间切换:

//switch to new window.
_driver.SwitchTo().Window(_driver.WindowHandles.Last());
//switch back to your first window
_driver.SwitchTo().Window(_driver.WindowHandles.First());

我知道这并不能完全满足你的需求,但也许它可以解决你的一些问题。

最新更新