SeleniumWebDriver FluentAutomation Chrome隐身

时间:2015-03-27 14:52:34

标签: c# google-chrome selenium-webdriver incognito-mode fluentautomation

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

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

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

1 个答案:

答案 0 :(得分:0)

我不确定如何始终强制它在icognito模式下运行,但您可以随时在隐身模式下打开新窗口并使用它。

_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());

我知道这不会让你感到兴奋,但也许它可以解决你的一些问题。