The coded ui Test in VS 2015 I have generated looks like:
[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
}
I know that if you pass the "-private" parameter to the launch function you can open IE in private mode. But I can't !!!
I can't because the launch function has no such overloaded function. Is there any way I can test my UI in private mode only each time. Please help. Thanks.
Well, I dont have a direct approach. But this hack should help you get what you want..
// 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"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.