VS 2015中的编码ui测试我生成的内容如下:
[GeneratedCode("Coded UITest Builder", "14.0.23107.0")]
public class UINewtabInternetExplorWindow : BrowserWindow
{
public UINewtabInternetExplorWindow()
{
#region Search Criteria
this.SearchProperties[UITestControl.PropertyNames.Name] = "New tab";
this.SearchProperties[UITestControl.PropertyNames.ClassName] = "IEFrame";
this.WindowTitles.Add("New tab");
this.WindowTitles.Add("Certificate Error: Navigation Blocked");
this.WindowTitles.Add("Home - Select Service");
this.WindowTitles.Add("Sign in to your account");
this.WindowTitles.Add("Home");
#endregion
}
public void LaunchUrl(System.Uri url)
{
this.CopyFrom(BrowserWindow.Launch(url)); // Can't Add -private
}
我知道if you pass the "-private" parameter to the launch function你可以在私人模式下打开IE。但我不能!!!
我不能,因为启动功能没有这样的重载功能。有没有办法我每次只能在私人模式下测试我的UI。请帮忙。感谢。
答案 0 :(得分:0)
好吧,我没有直接的方法。但是这个黑客可以帮助你得到你想要的东西..
// Start the Browser As Process to start in Private mode
Process browserProcess = new Process();
browserProcess.StartInfo.FileName = "iexplore.exe";
browserProcess.StartInfo.Arguments = "-private";
browserProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
// Start browser
browserProcess.Start();
// Get Process (Browser) Handle
Int64 browserHandle = browserProcess.Handle.ToInt64();
// Create a new Browser Instance & Assign the browser created as process using the window Handle
BrowserWindow browserFormHandle = new BrowserWindow();
browserFormHandle.SearchProperties.Add(BrowserWindow.PropertyNames.WindowHandle, browserFormHandle.ToString());
browserFormHandle.NavigateToUrl(new Uri("http://www.google.com"));