繁体   English   中英

编码的UI测试无法打开专用模式

[英]Coded UI Test Unable to Open Private Mode

我在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
    }

我知道, 如果将“ -private”参数传递给启动功能 ,则可以在私有模式下打开IE。 但是我不能!

我不能,因为启动功能没有这样的重载功能。 有什么办法可以让我每次仅在私有模式下测试UI。 请帮忙。 谢谢。

好吧,我没有直接的方法。 但是这种技巧应该可以帮助您获得所需的东西。

// 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"));

暂无
暂无

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

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