【发布时间】:2014-08-31 23:18:39
【问题描述】:
应用程序正在运行并且应用程序的窗口在屏幕上可见, 但是编码的 ui 测试总是得到 NullReferenceException:
- 采样 = 应用程序
- sampling.Window = 应用程序的主窗口
代码:
if(object.ReferenceEquals(sampling, null)) // sampling is not a null reference (debug output)
if(sampling == null) // sampling is not null
if(object.ReferenceEquals(sampling.Window, null)) // sampling.Window is not a null reference
if(sampling.Window == null) // sampling.Window is not null
if (sampling.Window.Exists) // sampling.Window exists? True
if(sampling.Window.TryGetClickablePoint(out pt)) // Got clickable point? False Point = {X=0,Y=0}
if(object.ReferenceEquals(sampling.Window.BoundingRectangle, null)) // Exception: object reference not set to an instance of an object.
if(object.ReferenceEquals(sampling.Window.ControlType, null)) // Exception: object reference not set to an instance of an object.
if(object.ReferenceEquals(sampling.Window.Name, null)) // Exception: object reference not set to an instance of an object.
if(object.ReferenceEquals(sampling.Window.ClassName, null)) // Exception: object reference not set to an instance of an object.
if(sampling.Window.BoundingRectangle == null) // Exception: object reference not set to an instance of an object.
if(sampling.Window.ControlType == null) // Exception: object reference not set to an instance of an object.
if(sampling.Window.Name == null) // Exception: object reference not set to an instance of an object.
if(sampling.Window.ClassName == null) // Exception: object reference not set to an instance of an object.
【问题讨论】:
-
您需要更好地格式化您的问题。代码应该被格式化,异常堆栈应该是块引号。您还应该用您使用的语言标记问题。
-
NullReferenceException的几乎所有情况都是相同的。请参阅“What is a NullReferenceException in .NET?”获取一些提示。
标签: c# visual-studio-2010 nullreferenceexception coded-ui-tests