通过 Cruise Control 服务在服务器上运行测试时,为什么必须在 WatiN 中附加 IE
我已经做了很长时间的以下操作,当我启动它时,它可以正常工作,没有任何问题:
[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 服务运行时为什么必须这样做?
I have been doing the following for the longest time and it works without any issues when I initiate it:
[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"));
}
The assertion method normally still has an ie that is intantiated. When the AssertionMethod executes, NewEmployeePage will just assume the currently open browser. Now when the AssertionMethod executes via a CruiseControl service (running under a service account), ie is null. I finally got around this issue by doing the following:
[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"));
}
I'm just wondering why I have to do this when my tests are ran by a CruiseControl service?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论