如何让 WatiN 在 Windows Server 2008 和 IE8 上运行?

发布于 2024-07-25 03:22:58 字数 1861 浏览 7 评论 0原文

我的问题是,我无法进行简单的 WatiN 测试来在运行 Windows Server 2008 和 IE8 的开发计算机上可靠地工作。

我看过一些关于此的好帖子,但仍然遇到问题。 以下是帖子:

第一篇文章中的步骤似乎有帮助(在我的主机文件中注释掉“::1”,将我的站点放在受信任的站点中,并确保我的app.config具有“STA”并设置为“如果较新则复制”,但它们并没有可靠地提供帮助我尝试了第二个示例中的代码,希望它能有所帮助,但我使用的是 WatiN 版本 2.0 beta 1。

我的 NUnit 代码如下所示:

protected Browser Browser { get; set; }

[TestFixtureSetUp]
public void SetupPriorToTestsInThisFixture()
{
    Browser = new IE();
    Browser.GoTo(Constants.SiteCollectionUrl);
}

[TestFixtureTearDown]
public void TearDownAfterTestsInThisFixture()
{
    if (Browser != null)
    {
        Browser.Dispose();
    }
}

[Test]
public void WaterThroughThePipes()
{
    Link link = Browser.Link(Find.ByText("Calendar"));
    bool exists = link.Exists;
    Assert.That(exists, Is.True, "Could not find 'Calendar' link.");
}

我看到的是有时(尽管很少)我的测试。有时断言失败(exists = false),有时尝试打开浏览器时超时,有时尝试访问 link.Exists 时出现错误访问 link.Exists 时出现

错误:

MyFixture.WaterThroughThePipes: System.Runtime.InteropServices.COMException:接口未知。 (HRESULT 异常:0x800706B5)

我现在似乎无法重现超时错误,因此我目前无法提供该错误(尽管这种情况过去经常发生)。

在调试模式下运行与不在调试模式下运行时,我倾向于看到不同的结果。

无论如何,Firefox 3.0.6 从来都不适合我。 我希望如此,但无论如何都需要 IE 才能工作。 这是我使用 Firefox 时遇到的错误。

MyFixture(TestFixtureSetUp): WatiN.Core.Native.Mozilla.FireFoxException:无法连接到 jssh 服务器,请确保您已正确安装 jssh.xpi 插件 ----> System.Net.Sockets.SocketException:无法建立连接,因为目标机器主动拒绝它127.0.0.1:9997

有什么想法吗? 我真的不想回到 Selenium(曾经去过那里,做过那件事),但我可能不得不这样做。

My problem is that I cannot get a simple WatiN test to reliably work on my development machine which is running Windows Server 2008 and IE8.

I have seen a couple of good posts on this, but am still having problems. Here are the posts:

The steps in the first article seemed to help (comment out "::1" in my hosts file, put my site(s) in trusted sites, and making sure my app.config has "STA" and is set to "copy if newer", but they did not help reliably. I tried the code from the second example hoping that it would help but it did not. I am using WatiN version 2.0 beta 1.

My NUnit code looks like the following:

protected Browser Browser { get; set; }

[TestFixtureSetUp]
public void SetupPriorToTestsInThisFixture()
{
    Browser = new IE();
    Browser.GoTo(Constants.SiteCollectionUrl);
}

[TestFixtureTearDown]
public void TearDownAfterTestsInThisFixture()
{
    if (Browser != null)
    {
        Browser.Dispose();
    }
}

[Test]
public void WaterThroughThePipes()
{
    Link link = Browser.Link(Find.ByText("Calendar"));
    bool exists = link.Exists;
    Assert.That(exists, Is.True, "Could not find 'Calendar' link.");
}

What I'm seeing is that sometimes (albeit rarely) my test passes. Sometimes the assertion fails (exists = false), sometimes I get a timeout when trying to open the browser, and sometimes I get an error trying to access link.Exists.

The error accessing link.Exists looks like:

MyFixture.WaterThroughThePipes:
System.Runtime.InteropServices.COMException : The interface is unknown. (Exception from HRESULT: 0x800706B5)

I can't seem to reproduce the timeout error now so I can't provide that at the moment (although this used to happen all of the time).

I tend to see different results when running this in debug mode vs. not running in debug mode.

For what it's worth, Firefox 3.0.6 has never worked for me. I'd like it to, but need IE to work regardless. Here is the error I get with Firefox.

MyFixture (TestFixtureSetUp):
WatiN.Core.Native.Mozilla.FireFoxException : Unable to connect to jssh server, please make sure you have correctly installed the jssh.xpi plugin
----> System.Net.Sockets.SocketException : No connection could be made because the target machine actively refused it 127.0.0.1:9997

Any ideas? I really don't want to go back to Selenium (been there, done that), but I may have to.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

通知家属抬走 2024-08-01 03:22:58

以管理员身份运行 Visual Studio

Run Visual Studio as Administrator

网白 2024-08-01 03:22:58

通过将我的互联网安全设置调整为“启用保护模式”,即使对于本地 Intranet 站点,我也能够消除此 COM 错误,并让我的测试正常运行。 这个复选框使一切变得不同。 (而且我不必以管理员身份运行 Visual Studio。)

请参阅此博文以修复此问题,而无需以管理员身份运行 Visual Studio。

简单来说:

在Internet Explorer中,打开“工具”->“工具”。 互联网选项 -> 安全-> 本地 Intranet 并选中“启用保护模式”框。

我在 Windows 7 上运行 IE 8 和 Visual Studio 2010。

I was able to get this COM error to go away -- and get my tests running normally -- by adjusting my Internet Security settings to "Enable Protected Mode" even for Local Intranet sites. This single checkbox made all the difference. (And I don't have to run Visual Studio as Administrator.)

See this blog post for fixing this problem without running Visual Studio as Administrator.

Briefly:

In Internet Explorer, open Tools -> Internet Options -> Security -> Local intranet and check the box "Enable Protected Mode."

I'm running IE 8 and Visual Studio 2010 on Windows 7.

很糊涂小朋友 2024-08-01 03:22:58

IE8 确实与 WatiN 合作,自 IE8 首次公开发布以来一直如此。

如果某些东西在调试中工作但在运行时不起作用,通常表明存在计时或 Server 2008 安全锁定问题。

您应该将失败的行放入 try catch 中,然后如果出现异常,则暂停半秒,然后重试。

还要确保您已关闭所有额外的服务器安全锁定,并以管理员身份运行 nUnit 以避免 UAC 妨碍。

IE8 definatley works with WatiN, and has done since the first public release of IE8.

If something is working in debug but not when running it usually points to a timing or Server 2008 security lockdown issue.

You should putting the line that is failing in a try catch, then if there is an exception pause for say half a sec and then re-try again.

Also ensure that you have turned off all the extra server security lockdowns, and are running nUnit as administrator to avoid UAC getting in the way.

め可乐爱微笑 2024-08-01 03:22:58

关于您在 Firefox 上看到的错误...可以通过安装 FireWatir 来解决FF 插件。 (或者至少在 3.5.3 上对我有用)

但正如已经提到的,IE 是受支持的,并且在 WatiN 上下文中,使用 FireFox 并不是神奇的解决方案。

Regarding the error you're seeing on firefox... That can be overcome by installing the FireWatir FF plugin. (Or at least that worked for me on 3.5.3)

But as already mentioned, IE is supported and in a WatiN context, using FireFox is no magic solution.

望笑 2024-08-01 03:22:58

避免以管理员身份运行 Visual Studio 或 NUnit 的另一种选择是在计算机级别禁用 UAC,如果您以最低权限运行(您应该如此),这不应该成为安全问题。

The other alternative to avoid running Visual Studio or NUnit as an admin would be to disable UAC at a machine level, which shouldn't be a security issue if you are running with least privileges (which you should be).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文