在编码 UI 测试中更改 BrowserWindow 中的 CurrentBrowser 变量值时出现问题

Troubles changing value of CurrentBrowser variable in BrowserWindow in Coded UI Tests

我已经在我的 Windows 服务器 2012 R2 中安装了 VS 2017(entrprise),并且我试图在我的编码 UI 测试中启动 IE(11) 浏览器。但是每次我 运行 下面提到的代码时,我都会看到 BrowserWindow.CurrentBrowser 值没有从 'IE'(默认值)更改为 'iexplore'(我要分配的值) . 它会抛出任何异常或错误,但它也不会更改 BrowserWindow.CurrentBrowser.

的值
            Uri gotourl = new Uri(uri);

            BrowserWindow.CurrentBrowser = "iexplore";

            BrowserWindow currentBrowserWindow = BrowserWindow.Launch();

            currentBrowserWindow.NavigateToUrl(gotourl);

有人可以帮忙吗?

原因是它无法找到播放程序集 class 的正确版本(即 Microsoft.VisualStudio.TestTools.UITesting 版本 14.0.0.0)。我添加了正确的版本,还添加了 Playback.Initialize();在代码之前它起作用了。

    Playback.Initialize();

    Uri gotourl = new Uri(uri);

    BrowserWindow.CurrentBrowser = "iexplore";

    BrowserWindow currentBrowserWindow = BrowserWindow.Launch();

    currentBrowserWindow.NavigateToUrl(gotourl);