我在获取Visual Studio 2013的编码UI测试框架以一致地找到HtmlDocument
时遇到问题。
我最近才经历过这个问题,它以前很有效。不幸的是,自从我创建这些测试以来,许多事情都发生了变化(包括我的Visual Studio和Internet Explorer版本等),因此很难确定是什么变化导致了这种情况。此外,它大约有2/3的时间工作,这使得故障排除更加困难。
在我的测试中,我让一组不同的用户登录到测试中的网站并执行各种操作。为了做到这一点,我通过UI测试生成器捕获了在按住shift的同时右键单击Internet Explorer按钮,然后单击"以不同用户身份运行"菜单选项的操作。测试继续输入用户凭据,并加载他们的主页。(每个用户在我的机器上都有一个个人资料,他们都有谷歌作为主页。)在BrowserWindow
上调用NavigateTo()
可以让我加载网站,测试从那里正式开始。
当我尝试呼叫NavigateTo()
时发生挂断,并给我以下错误:
注意:如果可以找到主页,则不存在处理任何以前的HtmlDocuments或BrowserWindows的问题。
... threw exception.
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException:
The playback failed to find the control with the given search properties.
Additional Details:
TechnologyName: 'MSAA'
ControlType: 'Button'
Name: 'Internet Explorer'
---> System.Runtime.InteropServices.COMException:
Error HRESULT E_FAIL has been returned from a call to a COM component..
编辑:有时我会得到这个错误:
...threw exception. Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: Unable to find Windows Internet Explorer window with 'Google - Internet Explorer' in the title. ---> Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details:
TechnologyName: 'MSAA'
ControlType: 'Window'
Name: 'Google - Internet Explorer'
类名:"IEFrame"--->System.Runtime.InteropServices.COMException:调用COM组件时返回错误HRESULT E_FAIL。。
我在BrowserWindow
、HtmlDocument
等上尝试了各种WaitFor
调用
我尝试过包括一个try
/catch
块,如果失败,它会忘记HtmlDocument
,然后再试一次(所以它研究HtmlDocument
)作为以防万一,但这也不起作用。
搜索庞大的知识网并没有帮助我找到如何解决这个问题(使用BrowserWindows
和HtmlDocuments
是一件微不足道的事情,我似乎只能找到与寻找特定控件有关的问题)。
有人对有什么想法或建议吗?我还可以尝试什么
好吧,我撒谎了。我发现了真正修复它的原因。我给了我的测试帐户对运行测试的机器的管理权限。易于理解的这可能并不理想,但如果测试帐户被泄露,它们就无法在其他地方做任何事情。
它似乎在没有管理权限的情况下运行应用程序,然后尝试在编码的UI测试中捕获它失败,因为该应用程序运行的权限比Visual Studio实例少。
所以我的基于角色的测试是有效的,而且它们是FAST。
我通过减少运行测试的PC上的计算负载来解决这个问题。看起来,一个没有运行应用程序"负担"的系统执行得很好。我不知道是什么条件造成了一个"负担沉重"的环境。