如何在Watin集成测试中正确检查服务器错误。

| 我正在尝试检测在watin测试期间是否遇到服务器错误。我以为下面的代码可以解决问题,但是在使用中,我在此行的测试执行过程中得到了一个N​​RE:(Text.Contains(\“ Server Error \”))。 有什么建议在这里做什么?尝试尝试捕获块似乎不是正确的选择。 谢谢。
public class WatinBrowser : IE
{
    public WatinBrowser(string url, bool createInNewProcess) : base(url, createInNewProcess)
    {
    }

    public override void WaitForComplete(int waitForCompleteTimeOut)
    {
        base.WaitForComplete(waitForCompleteTimeOut);
        if (Text.Contains(\"Server Error\"))
        {
            throw new ServerErrorException(\"A server error occured: \" + Text);
        }
    }
}

public class ServerErrorException : Exception
{
    public ServerErrorException(string message): base(message)
    {
    }
}
    
已邀请:
        我认为问题在于您正在覆盖带有超时参数的版本。这意味着可以在不加载文档的情况下控制返回到您的代码。 我建议: 覆盖不带有超时参数的方法的版本 在调用Contains方法之前添加一个空检查。 (2)的代码示例:
if(this.Text == null) throw new TimeoutException();

if(this.Text.Contains(\"Server Error\"))
{
    ...
}
    

要回复问题请先登录注册