我一直在做以下时间最长的时间,当我启动时它没有任何问题:
[Test]
public void GoToMethod()
{
// Pre: ie = new IE();
NewEmployeePage page = ie.Page<NewEmployeePage>();
page.GoTo(); // which launches IE
}
[Test]
public void AssertionMethod()
{
NewEmployeePage page = ie.Page<NewEmployeePage>();
Assert.That(page.FirstNameTextBox.Text, Is.EqualTo("John"));
}
断言方法通常仍然具有被实例化的ie。当AssertionMethod执行时,NewEmployeePage将假定当前打开的浏览器。现在当AssertionMethod通过CruiseControl服务(在服务帐户下运行)执行时,即为null。我终于解决了这个问题:
[Test]
public void AssertionMethod()
{
string url = ie.Url;
ie = IE.Attach<IE>(url);
NewEmployeePage page = ie.Page<NewEmployeePage>();
Assert.That(page.FirstNameTextBox.Text, Is.EqualTo("John"));
}
我只是想知道为什么在我的测试由CruiseControl服务运行时我必须这样做?