简体   繁体   English

SeleniumWebDriver FluentAutomation Chrome隐身

[英]SeleniumWebDriver FluentAutomation Chrome incognito

We are using FluentAutomation.SeleniumWebDriver to drive our integration tests. 我们正在使用FluentAutomation.SeleniumWebDriver来驱动我们的集成测试。 We configure this as so 我们这样配置

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

My question is how do I tell it to run in incognito mode? 我的问题是如何告诉我以隐身模式运行? The problem I have is that the tests will sometimes use cookies that I have been using locally and this can affect tests. 我的问题是测试有时会使用我在本地使用的cookie,这可能会影响测试。

I'm not sure how to always force it to run in icognito mode, but it might be helpfull that you can always open a new window in incognito mode and use that. 我不确定如何始终强制它以icognito模式运行,但是始终可以以隐身模式打开新窗口并使用它可能会有所帮助。

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

You can switch between windows as following: 您可以按以下方式在窗口之间切换:

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

I know this doesn't give you excatly what you wanted but maybe it can sovle some of your problems. 我知道这并不能完全满足您的需求,但也许可以解决您的一些问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM