How do I keep the browser open after a coded ui test finishes?

前端 未结 3 776
庸人自扰
庸人自扰 2021-01-21 01:32

I\'m using Visual Studio 2012 Coded UI tests for a web application. I have a test for logging into the app which starts the browser, locates the login dialogue, enters credenti

3条回答
  •  天命终不由人
    2021-01-21 02:07

    I don't have the original source where I found this solution :( You can have a method like the one showed below. This method needs to be called in TestSetup. Also declare a class level variable _browserWindow of the tyep BrowserWindow

    private void SetBrowser()
        {
            if(_browserWindow == null)
            {
                BrowserWindow.CurrentBrowser = "ie";
                _browserWindow = BrowserWindow.Launch("http://www.google.com");
                _browserWindow.CloseOnPlaybackCleanup = false;
               _browserWindow.Maximized = !_browserWindow.Maximized;
            }
            else
            {
                BrowserWindow.CurrentBrowser = "ie";
                _browserWindow = BrowserWindow.Locate("Google");
               _browserWindow.Maximized = !_browserWindow.Maximized;
            }
    
        }
    

提交回复
热议问题