相关疑难解决方法(0)

Visual Studio 2008中的WatiN - 第二种测试方法失败

当试图在Visual Studio 2008中运行一个非常简单的WatiN 2.0(CT​​P3)测试时,我发现第一个测试总是很好.第二个测试方法似乎破坏IE对象中的某些东西,产生以下异常:

测试方法testProject.WatinTest.testTwo抛出异常:System.Runtime.InteropServices.InvalidComObjectException:已经与其底层RCW分离的COM对象无法使用..

示例代码如下.由于初始化方法在VS2008中的工作方式,浏览器变量必须定义为static我认为可能是问题的关键.不幸的是,除非在常用方法中打开浏览器,否则它意味着每个测试的单独窗口并不理想

我会非常感谢有关如何解决这个问题的任何想法.谷歌搜索和SO搜索没有产生任何有用的结果,所以我希望这个问题的一个好的答案将有助于社区.非常感谢,


    private static IE ie

    [ClassInitialize]
    public static void testInit(TestContext testContext)
    {
        ie = new IE("http://news.bbc.co.uk");
    }

    [TestMethod]
    public void testOne()
    {
        Assert.IsTrue(ie.ContainsText("Low graphics"));
    }

    [TestMethod]
    public void testTwo()
    {
        Assert.IsTrue(ie.ContainsText("Low graphics"));
    }
Run Code Online (Sandbox Code Playgroud)

testing automation watin visual-studio

8
推荐指数
2
解决办法
3280
查看次数

标签 统计

automation ×1

testing ×1

visual-studio ×1

watin ×1